
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

    <title>Welcome to Tigramite’s documentation! &#8212; Tigramite 5.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <section id="welcome-to-tigramite-s-documentation">
<h1>Welcome to Tigramite’s documentation!<a class="headerlink" href="#welcome-to-tigramite-s-documentation" title="Permalink to this heading">¶</a></h1>
<div class="toctree-wrapper compound">
</div>
</section>
<section id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this heading">¶</a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</section>
<section id="tigramite">
<h1>TIGRAMITE<a class="headerlink" href="#tigramite" title="Permalink to this heading">¶</a></h1>
<p><a class="reference external" href="https://github.com/jakobrunge/tigramite/">Github repo</a></p>
<p>Tigramite is a causal time series analysis python package. It allows to efficiently estimate causal graphs from high-dimensional time series datasets (causal discovery) and to use these graphs for robust forecasting and the estimation and prediction of direct, total, and mediated effects. Causal discovery is based on linear as well as non-parametric conditional independence tests applicable to discrete or continuously-valued time series. Also includes functions for high-quality plots of the results. Please cite the following papers depending on which method you use:</p>
<ul class="simple">
<li><p>Overview: Runge, J., Gerhardus, A., Varando, G. et al. Causal inference for time series. Nat Rev Earth Environ (2023). <a class="reference external" href="https://doi.org/10.1038/s43017-023-00431-y">https://doi.org/10.1038/s43017-023-00431-y</a></p></li>
<li><p>PCMCI: J. Runge, P. Nowack, M. Kretschmer, S. Flaxman, D. Sejdinovic, Detecting and quantifying causal associations in large nonlinear time series datasets. Sci. Adv. 5, eaau4996 (2019). <a class="reference external" href="https://advances.sciencemag.org/content/5/11/eaau4996">https://advances.sciencemag.org/content/5/11/eaau4996</a></p></li>
<li><p>PCMCI+: J. Runge (2020): Discovering contemporaneous and lagged causal relations in autocorrelated nonlinear time series datasets. Proceedings of the 36th Conference on Uncertainty in Artificial Intelligence, UAI 2020,Toronto, Canada, 2019, AUAI Press, 2020. <a class="reference external" href="http://auai.org/uai2020/proceedings/579_main_paper.pdf">http://auai.org/uai2020/proceedings/579_main_paper.pdf</a></p></li>
<li><p>LPCMCI: Gerhardus, A. &amp; Runge, J. High-recall causal discovery for autocorrelated time series with latent confounders Advances in Neural Information Processing Systems, 2020, 33. <a class="reference external" href="https://proceedings.neurips.cc/paper/2020/hash/94e70705efae423efda1088614128d0b-Abstract.html">https://proceedings.neurips.cc/paper/2020/hash/94e70705efae423efda1088614128d0b-Abstract.html</a></p></li>
<li><p>RPCMCI: Elena Saggioro, Jana de Wiljes, Marlene Kretschmer, Jakob Runge; Reconstructing regime-dependent causal relationships from observational time series. Chaos 1 November 2020; 30 (11): 113115. <a class="reference external" href="https://doi.org/10.1063/5.0020538">https://doi.org/10.1063/5.0020538</a></p></li>
<li><p>JPCMCIplus: W. Günther, U. Ninad, J. Runge, Causal discovery for time series from multiple datasets with latent contexts. UAI 2023</p></li>
<li><p>Generally: J. Runge (2018): Causal Network Reconstruction from Time Series: From Theoretical Assumptions to Practical Estimation. Chaos: An Interdisciplinary Journal of Nonlinear Science 28 (7): 075310. <a class="reference external" href="https://aip.scitation.org/doi/10.1063/1.5025050">https://aip.scitation.org/doi/10.1063/1.5025050</a></p></li>
<li><p>Nature Communications Perspective paper: <a class="reference external" href="https://www.nature.com/articles/s41467-019-10105-3">https://www.nature.com/articles/s41467-019-10105-3</a></p></li>
<li><p>Causal effects: J. Runge, Necessary and sufficient graphical conditions for optimal adjustment sets in causal graphical models with hidden variables, Advances in Neural Information Processing Systems, 2021, 34</p></li>
<li><p>Mediation class: J. Runge et al. (2015): Identifying causal gateways and mediators in complex spatio-temporal systems. Nature Communications, 6, 8502. <a class="reference external" href="http://doi.org/10.1038/ncomms9502">http://doi.org/10.1038/ncomms9502</a></p></li>
<li><p>Mediation class: J. Runge (2015): Quantifying information transfer and mediation along causal pathways in complex systems. Phys. Rev. E, 92(6), 62829. <a class="reference external" href="http://doi.org/10.1103/PhysRevE.92.062829">http://doi.org/10.1103/PhysRevE.92.062829</a></p></li>
<li><p>CMIknn: J. Runge (2018): Conditional Independence Testing Based on a Nearest-Neighbor Estimator of Conditional Mutual Information. In Proceedings of the 21st International Conference on Artificial Intelligence and Statistics. <a class="reference external" href="http://proceedings.mlr.press/v84/runge18a.html">http://proceedings.mlr.press/v84/runge18a.html</a></p></li>
</ul>
<div class="toctree-wrapper compound">
</div>
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.pcmci.PCMCI" title="tigramite.pcmci.PCMCI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.pcmci.PCMCI</span></code></a>(dataframe, cond_ind_test)</p></td>
<td><p>PCMCI causal discovery for time series datasets.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.lpcmci.LPCMCI" title="tigramite.lpcmci.LPCMCI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.lpcmci.LPCMCI</span></code></a>(dataframe, cond_ind_test)</p></td>
<td><p>LPCMCI is an algorithm for causal discovery in large-scale times series that allows for latent confounders and learns lag-specific causal relationships.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.rpcmci.RPCMCI" title="tigramite.rpcmci.RPCMCI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.rpcmci.RPCMCI</span></code></a>(dataframe[, ...])</p></td>
<td><p>RPCMCI class for extracting causal regimes and the associated graphs from time series data.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.jpcmciplus.JPCMCIplus" title="tigramite.jpcmciplus.JPCMCIplus"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.jpcmciplus.JPCMCIplus</span></code></a>(...)</p></td>
<td><p>J-PCMCIplus causal discovery for time series datasets from multiple contexts.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.independence_tests_base.CondIndTest" title="tigramite.independence_tests.independence_tests_base.CondIndTest"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.independence_tests_base.CondIndTest</span></code></a>([...])</p></td>
<td><p>Base class of conditional independence tests.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.parcorr.ParCorr" title="tigramite.independence_tests.parcorr.ParCorr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.parcorr.ParCorr</span></code></a>(...)</p></td>
<td><p>Partial correlation test.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr" title="tigramite.independence_tests.robust_parcorr.RobustParCorr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.robust_parcorr.RobustParCorr</span></code></a>(...)</p></td>
<td><p>Robust partial correlation test based on non-paranormal models.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.gpdc.GPDC" title="tigramite.independence_tests.gpdc.GPDC"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.gpdc.GPDC</span></code></a>([...])</p></td>
<td><p>GPDC conditional independence test based on Gaussian processes and distance correlation.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch" title="tigramite.independence_tests.gpdc_torch.GPDCtorch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.gpdc_torch.GPDCtorch</span></code></a>([...])</p></td>
<td><p>GPDC conditional independence test based on Gaussian processes and distance correlation.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.cmiknn.CMIknn" title="tigramite.independence_tests.cmiknn.CMIknn"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.cmiknn.CMIknn</span></code></a>([...])</p></td>
<td><p>Conditional mutual information test based on nearest-neighbor estimator.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.cmisymb.CMIsymb" title="tigramite.independence_tests.cmisymb.CMIsymb"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.cmisymb.CMIsymb</span></code></a>([...])</p></td>
<td><p>Conditional mutual information test for discrete/categorical data.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI" title="tigramite.independence_tests.oracle_conditional_independence.OracleCI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.oracle_conditional_independence.OracleCI</span></code></a>([...])</p></td>
<td><p>Oracle of conditional independence test X _|_ Y | Z given a graph.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult" title="tigramite.independence_tests.parcorr_mult.ParCorrMult"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.parcorr_mult.ParCorrMult</span></code></a>([...])</p></td>
<td><p>Partial correlation test for multivariate X and Y.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.gsquared.Gsquared" title="tigramite.independence_tests.gsquared.Gsquared"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.gsquared.Gsquared</span></code></a>([...])</p></td>
<td><p>G-squared conditional independence test for categorical data.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.independence_tests.parcorr_wls.ParCorrWLS" title="tigramite.independence_tests.parcorr_wls.ParCorrWLS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.parcorr_wls.ParCorrWLS</span></code></a>([...])</p></td>
<td><p>Weighted partial correlation test.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.independence_tests.regressionCI.RegressionCI" title="tigramite.independence_tests.regressionCI.RegressionCI"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.independence_tests.regressionCI.RegressionCI</span></code></a>(...)</p></td>
<td><p>Flexible parametric conditional independence tests for continuous, categorical, or mixed data.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.causal_effects.CausalEffects" title="tigramite.causal_effects.CausalEffects"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.causal_effects.CausalEffects</span></code></a>(...)</p></td>
<td><p>Causal effect estimation.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.models.Models" title="tigramite.models.Models"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Models</span></code></a>(dataframe, model[, ...])</p></td>
<td><p>Base class for time series models.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tigramite.models.LinearMediation" title="tigramite.models.LinearMediation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.LinearMediation</span></code></a>(dataframe)</p></td>
<td><p>Linear mediation analysis for time series models.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tigramite.models.Prediction" title="tigramite.models.Prediction"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.models.Prediction</span></code></a>(dataframe, ...)</p></td>
<td><p>Prediction class for time series models.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#module-tigramite.data_processing" title="tigramite.data_processing"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.data_processing</span></code></a></p></td>
<td><p>Tigramite data processing functions.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#module-tigramite.toymodels.structural_causal_processes" title="tigramite.toymodels.structural_causal_processes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.toymodels.structural_causal_processes</span></code></a></p></td>
<td><p>Tigramite toymodels.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#module-tigramite.plotting" title="tigramite.plotting"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tigramite.plotting</span></code></a></p></td>
<td><p>Tigramite plotting package.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="tigramite-pcmci-pcmci">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.pcmci</span></code>: PCMCI<a class="headerlink" href="#tigramite-pcmci-pcmci" title="Permalink to this heading">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.pcmci.</span></span><span class="sig-name descname"><span class="pre">PCMCI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cond_ind_test</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI" title="Permalink to this definition">¶</a></dt>
<dd><p>PCMCI causal discovery for time series datasets.</p>
<p>PCMCI is a causal discovery framework for large-scale time series
datasets. This class contains several methods. The standard PCMCI method
addresses time-lagged causal discovery and is described in Ref [1] where
also further sub-variants are discussed. Lagged as well as contemporaneous
causal discovery is addressed with PCMCIplus and described in [5]. See the
tutorials for guidance in applying these methods.</p>
<p>PCMCI has:</p>
<ul class="simple">
<li><p>different conditional independence tests adapted to linear or
nonlinear dependencies, and continuously-valued or discrete data (
implemented in <code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>)</p></li>
<li><p>(mostly) hyperparameter optimization</p></li>
<li><p>easy parallelization (separate script)</p></li>
<li><p>handling of masked time series data</p></li>
<li><p>false discovery control and confidence interval estimation</p></li>
</ul>
<p class="rubric">Notes</p>
<a class="reference internal image-reference" href="_images/mci_schematic.png"><img alt="_images/mci_schematic.png" src="_images/mci_schematic.png" style="width: 200pt;" /></a>
<p>In the PCMCI framework, the dependency structure of a set of time series
variables is represented in a <em>time series graph</em> as shown in the Figure.
The nodes of a time series graph are defined as the variables at
different times and a link indicates a conditional dependency that can be
interpreted as a causal dependency under certain assumptions (see paper).
Assuming stationarity, the links are repeated in time. The parents
<img class="math" src="_images/math/fff7b4153a6590df59f8ed526be56220045b7f3b.png" alt="\mathcal{P}"/> of a variable are defined as the set of all nodes
with a link towards it (blue and red boxes in Figure).</p>
<p>The different PCMCI methods estimate causal links by iterative
conditional independence testing. PCMCI can be flexibly combined with
any kind of conditional independence test statistic adapted to the kind
of data (continuous or discrete) and its assumed dependency types.
These are available in <code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>.</p>
<p>NOTE: MCI test statistic values define a particular measure of causal
strength depending on the test statistic used. For example, ParCorr()
results in normalized values between -1 and 1. However, if you are
interested in quantifying causal effects, i.e., the effect of
hypothetical interventions, you may better look at the causal effect
estimation functionality of Tigramite.</p>
<p class="rubric">References</p>
<dl class="simple">
<dt>[1] J. Runge, P. Nowack, M. Kretschmer, S. Flaxman, D. Sejdinovic,</dt><dd><p>Detecting and quantifying causal associations in large nonlinear time
series datasets. Sci. Adv. 5, eaau4996 (2019)
<a class="reference external" href="https://advances.sciencemag.org/content/5/11/eaau4996">https://advances.sciencemag.org/content/5/11/eaau4996</a></p>
</dd>
<dt>[5] J. Runge,</dt><dd><p>Discovering contemporaneous and lagged causal relations in
autocorrelated nonlinear time series datasets
<a class="reference external" href="http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf">http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf</a></p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – This is the Tigramite dataframe object. Among others, it has the
attributes dataframe.values yielding a numpy array of shape (
observations T, variables N) and optionally a mask of the same shape.</p></li>
<li><p><strong>cond_ind_test</strong> (<em>conditional independence test object</em>) – This can be ParCorr or other classes from
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code> or an external test passed as a
callable. This test can be based on the class
tigramite.independence_tests.CondIndTest.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Verbose levels 0, 1, …</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.all_parents">
<span class="sig-name descname"><span class="pre">all_parents</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.all_parents" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the conditioning-parents estimated with PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.val_min">
<span class="sig-name descname"><span class="pre">val_min</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.val_min" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form val_min[j][(i, -tau)] = float
containing the minimum test statistic value for each link estimated in
the PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.pval_max">
<span class="sig-name descname"><span class="pre">pval_max</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.pval_max" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form pval_max[j][(i, -tau)] = float containing the maximum
p-value for each link estimated in the PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.iterations">
<span class="sig-name descname"><span class="pre">iterations</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.iterations" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary containing further information on algorithm steps.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.N">
<span class="sig-name descname"><span class="pre">N</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.N" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of variables.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.T">
<span class="sig-name descname"><span class="pre">T</span></span><a class="headerlink" href="#tigramite.pcmci.PCMCI.T" title="Permalink to this definition">¶</a></dt>
<dd><p>Time series sample length of dataset(s).</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.get_graph_from_pmatrix">
<span class="sig-name descname"><span class="pre">get_graph_from_pmatrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.get_graph_from_pmatrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.get_graph_from_pmatrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct graph from thresholding the p_matrix at an alpha-level.</p>
<p>Allows to take into account link_assumptions.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p_matrix</strong> (<em>array of shape</em><em> [</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>tau_mix</strong> (<em>int</em>) – Minimum time delay to test.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em>) – Maximum time delay to test.</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em><em> or </em><em>None</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>graph</strong> – Causal graph, see description above for interpretation.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape [N, N, tau_max+1]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.get_lagged_dependencies">
<span class="sig-name descname"><span class="pre">get_lagged_dependencies</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.get_lagged_dependencies"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.get_lagged_dependencies" title="Permalink to this definition">¶</a></dt>
<dd><p>Unconditional lagged independence tests.</p>
<p>Implements the unconditional lagged independence test (see [ 1]_).</p>
<p>Returns the matrices of test statistic values, (optionally corrected)
p-values, and (optionally) confidence intervals. Also (new in 4.3)
returns graph based on alpha_level (and optional FDR-correction).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>default: 0</em>) – Minimum time lag to test. Note that zero-lags are undirected.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>val_only</strong> (<em>bool</em><em>, </em><em>default: False</em>) – Option to only compute dependencies and not p-values.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'none'</em><em>)</em>) – Correction method, currently implemented is Benjamini-Hochberg
False Discovery Rate method (‘fdr_bh’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array of shape [N, N, tau_max+1,2]</em>) – Estimated matrix of confidence intervals of test statistic values.
Only computed if set in cond_ind_test, where also the percentiles
are set.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.print_results">
<span class="sig-name descname"><span class="pre">print_results</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">return_dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.print_results"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.print_results" title="Permalink to this definition">¶</a></dt>
<dd><p>Prints significant parents from output of MCI or PCMCI algorithms.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>return_dict</strong> (<em>dict</em>) – <dl class="simple">
<dt>Dictionary of return values, containing keys</dt><dd><ul>
<li><p>’p_matrix’</p></li>
<li><p>’val_matrix’</p></li>
<li><p>’conf_matrix’</p></li>
</ul>
</dd>
</dl>
</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.print_significant_links">
<span class="sig-name descname"><span class="pre">print_significant_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">graph</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ambiguous_triples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.print_significant_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.print_significant_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Prints significant links.</p>
<p>Used for output of PCMCI and PCMCIplus. For the latter also information
on ambiguous links and conflicts is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level.</p></li>
<li><p><strong>p_matrix</strong> (<em>array-like</em>) – Must be of shape (N, N, tau_max + 1).</p></li>
<li><p><strong>val_matrix</strong> (<em>array-like</em>) – Must be of shape (N, N, tau_max + 1).</p></li>
<li><p><strong>conf_matrix</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Matrix of confidence intervals of shape (N, N, tau_max+1, 2).</p></li>
<li><p><strong>graph</strong> (<em>array-like</em>) – Must be of shape (N, N, tau_max + 1).</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.return_parents_dict">
<span class="sig-name descname"><span class="pre">return_parents_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_lagzero_parents</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.return_parents_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.return_parents_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns dictionary of parents sorted by val_matrix.</p>
<p>If parents are unclear (edgemarks with ‘o’ or ‘x’, or middle mark ‘?’),
then no parent is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape</em><em> [</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array-like</em>) – Matrix of test statistic values. Must be of shape (N, N, tau_max +
1).</p></li>
<li><p><strong>include_lagzero_parents</strong> (<em>bool</em><em> (</em><em>default: False</em><em>)</em>) – Whether the dictionary should also return parents at lag
zero.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>parents_dict</strong> – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …}
containing estimated parents.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.return_significant_links">
<span class="sig-name descname"><span class="pre">return_significant_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pq_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_lagzero_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.return_significant_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.return_significant_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns list of significant links as well as a boolean matrix.</p>
<p>DEPRECATED. Will be removed in future.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_bivci">
<span class="sig-name descname"><span class="pre">run_bivci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_bivci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_bivci" title="Permalink to this definition">¶</a></dt>
<dd><p>BivCI conditional independence tests.</p>
<p>Implements the BivCI test (see <a class="footnote-reference brackets" href="#id5" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>).</p>
<p>Returns the matrices of test statistic values, (optionally corrected)
p-values, and (optionally) confidence intervals. Also (new in 4.3)
returns graph based on alpha_level (and optional FDR-correction).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>default: 0</em>) – Minimum time lag to test. Note that zero-lags are undirected.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>val_only</strong> (<em>bool</em><em>, </em><em>default: False</em>) – Option to only compute dependencies and not p-values.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'fdr_bh'</em><em>)</em>) – Correction method, currently implemented is Benjamini-Hochberg
False Discovery Rate method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array of shape [N, N, tau_max+1,2]</em>) – Estimated matrix of confidence intervals of test statistic values.
Only computed if set in cond_ind_test, where also the percentiles
are set.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_fullci">
<span class="sig-name descname"><span class="pre">run_fullci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_fullci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_fullci" title="Permalink to this definition">¶</a></dt>
<dd><p>FullCI conditional independence tests.</p>
<p>Implements the FullCI test (see <a class="footnote-reference brackets" href="#id5" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>).</p>
<p>Returns the matrices of test statistic values, (optionally corrected)
p-values, and (optionally) confidence intervals. Also (new in 4.3)
returns graph based on alpha_level (and optional FDR-correction).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>default: 0</em>) – Minimum time lag to test. Note that zero-lags are undirected.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>val_only</strong> (<em>bool</em><em>, </em><em>default: False</em>) – Option to only compute dependencies and not p-values.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'none'</em><em>)</em>) – Correction method, currently implemented is Benjamini-Hochberg
False Discovery Rate method (‘fdr_bh’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array of shape [N, N, tau_max+1,2]</em>) – Estimated matrix of confidence intervals of test statistic values.
Only computed if set in cond_ind_test, where also the percentiles
are set.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_mci">
<span class="sig-name descname"><span class="pre">run_mci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_mci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_mci" title="Permalink to this definition">¶</a></dt>
<dd><p>MCI conditional independence tests.</p>
<p>Implements the MCI test (Algorithm 2 in <a class="footnote-reference brackets" href="#id5" id="id3" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>).</p>
<p>Returns the matrices of test statistic values, (optionally corrected)
p-values, and (optionally) confidence intervals. Also (new in 4.3)
returns graph based on alpha_level (and optional FDR-correction).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>default: 0</em>) – Minimum time lag to test. Note that zero-lags are undirected.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>parents</strong> (<em>dict</em><em> or </em><em>None</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …}
specifying the conditions for each variable. If None is
passed, no conditions are used.</p></li>
<li><p><strong>max_conds_py</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum number of conditions of Y to use. If None is passed, this
number is unrestricted.</p></li>
<li><p><strong>max_conds_px</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum number of conditions of Z to use. If None is passed, this
number is unrestricted.</p></li>
<li><p><strong>val_only</strong> (<em>bool</em><em>, </em><em>default: False</em>) – Option to only compute dependencies and not p-values.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'none'</em><em>)</em>) – Correction method, currently implemented is Benjamini-Hochberg
False Discovery Rate method (‘fdr_bh’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array of shape [N, N, tau_max+1,2]</em>) – Estimated matrix of confidence intervals of test statistic values.
Only computed if set in cond_ind_test, where also the percentiles
are set.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_pc_stable">
<span class="sig-name descname"><span class="pre">run_pc_stable</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_iterations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_pc_stable"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_pc_stable" title="Permalink to this definition">¶</a></dt>
<dd><p>Lagged PC algorithm for estimating lagged parents of all variables.</p>
<p>Parents are made available as self.all_parents</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Minimum time lag to test. Useful for multi-step ahead predictions.
Must be greater zero.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>save_iterations</strong> (<em>bool</em><em>, </em><em>default: False</em>) – Whether to save iteration step results such as conditions used.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em> or </em><em>list of floats</em><em>, </em><em>default:</em><em> [</em><em>0.05</em><em>, </em><em>0.1</em><em>, </em><em>0.2</em><em>, </em><em>...</em><em>, </em><em>0.5</em><em>]</em>) – Significance level in algorithm. If a list or None is passed, the
pc_alpha level is optimized for every variable across the given
pc_alpha values using the score computed in
cond_ind_test.get_model_selection_criterion().</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum number of combinations of conditions of current cardinality
to test in PC1 step.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>all_parents</strong> – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …}
containing estimated parents.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_pcalg">
<span class="sig-name descname"><span class="pre">run_pcalg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lagged_parents</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'standard'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contemp_collider_rule</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'majority'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conflict_resolution</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_pcalg"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_pcalg" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs PC algorithm for time-lagged and contemporaneous causal
discovery for time series.</p>
<p>For <code class="docutils literal notranslate"><span class="pre">mode='contemp_conds'</span></code> this implements Steps 2-4 of the
PCMCIplus method described in [5]. For <code class="docutils literal notranslate"><span class="pre">mode='standard'</span></code> this
implements the standard PC algorithm adapted to time series.</p>
<p>[5] J. Runge, Discovering contemporaneous and lagged causal relations
in autocorrelated nonlinear time series datasets
<a class="reference external" href="http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf">http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf</a></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>lagged_parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
additional conditions for each CI test. As part of PCMCIplus
these are the superset of lagged parents estimated with the PC1
algorithm.</p></li>
<li><p><strong>mode</strong> (<em>{'standard'</em><em>, </em><em>'contemp_conds'}</em>) – For <code class="docutils literal notranslate"><span class="pre">mode='contemp_conds'</span></code> this implements Steps 2-4 of the
PCMCIplus method. For <code class="docutils literal notranslate"><span class="pre">mode='standard'</span></code> this implements the
standard PC algorithm adapted to time series.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Minimum time lag to test.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.01</em><em>)</em>) – Significance level.</p></li>
<li><p><strong>contemp_collider_rule</strong> (<em>{'majority'</em><em>, </em><em>'conservative'</em><em>, </em><em>'none'}</em>) – Rule for collider phase to use. See the paper for details. Only
‘majority’ and ‘conservative’ lead to an order-independent
algorithm.</p></li>
<li><p><strong>conflict_resolution</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to mark conflicts in orientation rules. Only for True
this leads to an order-independent algorithm.</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em>) – Maximum number of combinations of conditions of current cardinality
to test. Must be infinite (default for max_combinations=1) for consistency.</p></li>
<li><p><strong>max_conds_py</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of Y to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px_lagged</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X when X is lagged in MCI
tests. If None is passed, this number is equal to max_conds_px.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>sepsets</strong> (<em>dictionary</em>) – Separating sets. See paper for details.</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples, only relevant for ‘majority’ and
‘conservative’ rules, see paper for details.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_pcalg_non_timeseries_data">
<span class="sig-name descname"><span class="pre">run_pcalg_non_timeseries_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contemp_collider_rule</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'majority'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conflict_resolution</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_pcalg_non_timeseries_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_pcalg_non_timeseries_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs PC algorithm for non-time series data.</p>
<p>Simply calls run_pcalg with tau_min = tau_max = 0.
Removes lags from output dictionaries.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pc_alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.01</em><em>)</em>) – Significance level.</p></li>
<li><p><strong>contemp_collider_rule</strong> (<em>{'majority'</em><em>, </em><em>'conservative'</em><em>, </em><em>'none'}</em>) – Rule for collider phase to use. See the paper for details. Only
‘majority’ and ‘conservative’ lead to an order-independent
algorithm.</p></li>
<li><p><strong>conflict_resolution</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to mark conflicts in orientation rules. Only for True
this leads to an order-independent algorithm.</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em>) – Maximum number of combinations of conditions of current cardinality
to test. Must be infinite (default for max_combinations=1) for consistency.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, 1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, 1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, 1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>sepsets</strong> (<em>dictionary</em>) – Separating sets. See paper for details.</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples, only relevant for ‘majority’ and
‘conservative’ rules, see paper for details.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_pcmci">
<span class="sig-name descname"><span class="pre">run_pcmci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_iterations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_pcmci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_pcmci" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs PCMCI time-lagged causal discovery for time series.</p>
<p>Wrapper around PC-algorithm function and MCI function.</p>
<p class="rubric">Notes</p>
<p>The PCMCI causal discovery method is comprehensively described in [
1]_, where also analytical and numerical results are presented. Here
we briefly summarize the method.</p>
<p>PCMCI estimates time-lagged causal links by a two-step procedure:</p>
<ol class="arabic simple">
<li><p>Condition-selection: For each variable <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/>, estimate a
<em>superset</em> of parents <img class="math" src="_images/math/c4ed4f54ee00448249d2df22ad67f3e281df085b.png" alt="\tilde{\mathcal{P}}(X^j_t)"/> with the
iterative PC1 algorithm, implemented as <code class="docutils literal notranslate"><span class="pre">run_pc_stable</span></code>. The
condition-selection step reduces the dimensionality and avoids
conditioning on irrelevant variables.</p></li>
<li><p><em>Momentary conditional independence</em> (MCI)</p></li>
</ol>
<div class="math">
<p><img src="_images/math/e676f7877e03a3707387149ce203c5e79ed8f9a9.png" alt="X^i_{t-\tau} \perp X^j_{t} | \tilde{\mathcal{P}}(
X^j_t), \tilde{\mathcal{P}}(X^i_{t-\tau})"/></p>
</div><p>here implemented as <code class="docutils literal notranslate"><span class="pre">run_mci</span></code>. This step estimates the p-values and
test statistic values for all links accounting for common drivers,
indirect links, and autocorrelation.</p>
<p>NOTE: MCI test statistic values define a particular measure of causal
strength depending on the test statistic used. For example, ParCorr()
results in normalized values between -1 and 1. However, if you are
interested in quantifying causal effects, i.e., the effect of
hypothetical interventions, you may better look at the causal effect
estimation functionality of Tigramite.</p>
<p>PCMCI can be flexibly combined with any kind of conditional
independence test statistic adapted to the kind of data (continuous
or discrete) and its assumed dependency types. These are available in
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>.</p>
<p>The main free parameters of PCMCI (in addition to free parameters of
the conditional independence test statistic) are the maximum time
delay <img class="math" src="_images/math/2bf86ca220f43e569c6c7aefaf32742919222e6e.png" alt="\tau_{\max}"/> (<code class="docutils literal notranslate"><span class="pre">tau_max</span></code>) and the significance
threshold in the condition-selection step <img class="math" src="_images/math/2f5aa019312e1bbc969deab8dca8b00f76025404.png" alt="\alpha"/> (
<code class="docutils literal notranslate"><span class="pre">pc_alpha</span></code>). The maximum time delay depends on the application and
should be chosen according to the maximum causal time lag expected in
the complex system. We recommend a rather large choice that includes
peaks in the <code class="docutils literal notranslate"><span class="pre">get_lagged_dependencies</span></code> function. <img class="math" src="_images/math/2f5aa019312e1bbc969deab8dca8b00f76025404.png" alt="\alpha"/>
should not be seen as a significance test level in the
condition-selection step since the iterative hypothesis tests do not
allow for a precise assessment. <img class="math" src="_images/math/2f5aa019312e1bbc969deab8dca8b00f76025404.png" alt="\alpha"/> rather takes the role
of a regularization parameter in model-selection techniques. If a
list of values is given or <code class="docutils literal notranslate"><span class="pre">pc_alpha=None</span></code>, <img class="math" src="_images/math/2f5aa019312e1bbc969deab8dca8b00f76025404.png" alt="\alpha"/> is
optimized using model selection criteria implemented in the respective
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>.</p>
<p>Further optional parameters are discussed in <a class="footnote-reference brackets" href="#id5" id="id4" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">tigramite.pcmci</span> <span class="kn">import</span> <span class="n">PCMCI</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">tigramite.independence_tests</span> <span class="kn">import</span> <span class="n">ParCorr</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">tigramite.data_processing</span> <span class="k">as</span> <span class="nn">pp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">tigramite.toymodels</span> <span class="kn">import</span> <span class="n">structural_causal_processes</span> <span class="k">as</span> <span class="n">toys</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">numpy</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">7</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Example process to play around with</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Each key refers to a variable and the incoming links are supplied</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># as a list of format [((driver, -lag), coeff), ...]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">links_coeffs</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="p">[((</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="mf">0.8</span><span class="p">)],</span>
<span class="go">                    1: [((1, -1), 0.8), ((0, -1), 0.5)],</span>
<span class="go">                    2: [((2, -1), 0.8), ((1, -2), -0.6)]}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">toys</span><span class="o">.</span><span class="n">var_process</span><span class="p">(</span><span class="n">links_coeffs</span><span class="p">,</span> <span class="n">T</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Data must be array of shape (time, variables)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="go">(1000, 3)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">pp</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cond_ind_test</span> <span class="o">=</span> <span class="n">ParCorr</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pcmci</span> <span class="o">=</span> <span class="n">PCMCI</span><span class="p">(</span><span class="n">dataframe</span><span class="o">=</span><span class="n">dataframe</span><span class="p">,</span> <span class="n">cond_ind_test</span><span class="o">=</span><span class="n">cond_ind_test</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">results</span> <span class="o">=</span> <span class="n">pcmci</span><span class="o">.</span><span class="n">run_pcmci</span><span class="p">(</span><span class="n">tau_max</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">pc_alpha</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pcmci</span><span class="o">.</span><span class="n">print_significant_links</span><span class="p">(</span><span class="n">p_matrix</span><span class="o">=</span><span class="n">results</span><span class="p">[</span><span class="s1">&#39;p_matrix&#39;</span><span class="p">],</span>
<span class="go">                                 val_matrix=results[&#39;val_matrix&#39;],</span>
<span class="go">                                 alpha_level=0.05)</span>
<span class="go">## Significant parents at alpha = 0.05:</span>
</pre></div>
</div>
<blockquote>
<div><dl class="simple">
<dt>Variable 0 has 1 link(s):</dt><dd><p>(0 -1): pval = 0.00000 | val =  0.588</p>
</dd>
<dt>Variable 1 has 2 link(s):</dt><dd><p>(1 -1): pval = 0.00000 | val =  0.606
(0 -1): pval = 0.00000 | val =  0.447</p>
</dd>
<dt>Variable 2 has 2 link(s):</dt><dd><p>(2 -1): pval = 0.00000 | val =  0.618
(1 -2): pval = 0.00000 | val = -0.499</p>
</dd>
</dl>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Minimum time lag to test. Note that zero-lags are undirected.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>save_iterations</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to save iteration step results such as conditions used.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level in algorithm.</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum number of combinations of conditions of current cardinality
to test in PC1 step.</p></li>
<li><p><strong>max_conds_py</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions of Y to use. If None is passed, this
number is unrestricted.</p></li>
<li><p><strong>max_conds_px</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions of Z to use. If None is passed, this
number is unrestricted.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'fdr_bh'</em><em>)</em>) – Correction method, currently implemented is Benjamini-Hochberg
False Discovery Rate method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values, optionally adjusted if fdr_method is
not ‘none’.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array of shape [N, N, tau_max+1,2]</em>) – Estimated matrix of confidence intervals of test statistic values.
Only computed if set in cond_ind_test, where also the percentiles
are set.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.pcmci.PCMCI.run_pcmciplus">
<span class="sig-name descname"><span class="pre">run_pcmciplus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contemp_collider_rule</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'majority'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conflict_resolution</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset_lagged_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/pcmci.html#PCMCI.run_pcmciplus"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.pcmci.PCMCI.run_pcmciplus" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs PCMCIplus time-lagged and contemporaneous causal discovery for
time series.</p>
<p>Method described in [5]:
<a class="reference external" href="http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf">http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf</a></p>
<p>[5] J. Runge, Discovering contemporaneous and lagged causal relations
in autocorrelated nonlinear time series datasets
<a class="reference external" href="http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf">http://www.auai.org/~w-auai/uai2020/proceedings/579_main_paper.pdf</a></p>
<p class="rubric">Notes</p>
<p>The PCMCIplus causal discovery method is described in [5], where
also analytical and numerical results are presented. In contrast to
PCMCI, PCMCIplus can identify the full, lagged and contemporaneous,
causal graph (up to the Markov equivalence class for contemporaneous
links) under the standard assumptions of Causal Sufficiency,
Faithfulness and the Markov condition.</p>
<p>PCMCIplus estimates time-lagged and contemporaneous causal links by a
four-step procedure:</p>
<p>1.  Condition-selection (same as for PCMCI): For each variable
<img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/>, estimate a <em>superset</em> of lagged parents <img class="math" src="_images/math/15af846e07c93e1c0d4cdbba8f4cefca67a811cb.png" alt="\widehat{
\mathcal{B}}_t^-( X^j_t)"/> with the iterative PC1 algorithm,
implemented as <code class="docutils literal notranslate"><span class="pre">run_pc_stable</span></code>. The condition-selection step
reduces the dimensionality and avoids conditioning on irrelevant
variables.</p>
<p>2.   PC skeleton phase with contemporaneous conditions and <em>Momentary
conditional independence</em> (MCI) tests: Iterate through subsets
<img class="math" src="_images/math/f852990c4a225a95d2c694a9f1351f54bac3ba86.png" alt="\mathcal{S}"/> of contemporaneous adjacencies and conduct MCI
conditional independence tests:</p>
<div class="math">
<p><img src="_images/math/d4ac9b60213cb2ffe02c6d5dacac8796221c73ac.png" alt="X^i_{t-\tau} ~\perp~ X^j_{t} ~|~ \mathcal{S},
\widehat{\mathcal{B}}_t^-(X^j_t),
\widehat{\mathcal{B}}_{t-\tau}^-(X^i_{t-{\tau}})"/></p>
</div><p>here implemented as <code class="docutils literal notranslate"><span class="pre">run_pcalg</span></code>. This step estimates the p-values and
test statistic values for all lagged and contemporaneous adjacencies
accounting for common drivers, indirect links, and autocorrelation.</p>
<p>3.   PC collider orientation phase: Orient contemporaneous collider
motifs based on unshielded triples. Optionally apply conservative or
majority rule (also based on MCI tests).</p>
<p>4.   PC rule orientation phase: Orient remaining contemporaneous
links based on PC rules.</p>
<p>In contrast to PCMCI, the relevant output of PCMCIplus is the
array <code class="docutils literal notranslate"><span class="pre">graph</span></code>. Its string entries are interpreted as follows:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">graph[i,j,tau]=--&gt;</span></code> for <img class="math" src="_images/math/2882aa5d9b56c4f42679de5f902a74d8ae88a624.png" alt="\tau&gt;0"/> denotes a directed, lagged
causal link from <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/> to <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/> at lag <img class="math" src="_images/math/914b2d4b6659b86d3153d5510839dfb254dfc8a3.png" alt="\tau"/></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">graph[i,j,0]=--&gt;</span></code> (and <code class="docutils literal notranslate"><span class="pre">graph[j,i,0]=&lt;--</span></code>) denotes a directed,
contemporaneous causal link from <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/> to <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">graph[i,j,0]=o-o</span></code> (and <code class="docutils literal notranslate"><span class="pre">graph[j,i,0]=o-o</span></code>) denotes an unoriented,
contemporaneous adjacency between <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/> and <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/> indicating
that the collider and orientation rules could not be applied (Markov
equivalence)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">graph[i,j,0]=x-x</span></code> and (<code class="docutils literal notranslate"><span class="pre">graph[j,i,0]=x-x</span></code>) denotes a conflicting,
contemporaneous adjacency between <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/> and <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/> indicating
that the directionality is undecided due to conflicting orientation
rules</p></li>
</ul>
<p>Importantly, <code class="docutils literal notranslate"><span class="pre">p_matrix</span></code> and <code class="docutils literal notranslate"><span class="pre">val_matrix</span></code> for PCMCIplus quantify
the uncertainty and strength, respectively, only for the
adjacencies, but not for the directionality of contemporaneous links.
Note that lagged links are always oriented due to time order.</p>
<p>PCMCIplus can be flexibly combined with any kind of conditional
independence test statistic adapted to the kind of data (continuous
or discrete) and its assumed dependency types. These are available in
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>.</p>
<p>The main free parameters of PCMCIplus (in addition to free parameters of
the conditional independence tests) are the maximum time delay
<img class="math" src="_images/math/2bf86ca220f43e569c6c7aefaf32742919222e6e.png" alt="\tau_{\max}"/> (<code class="docutils literal notranslate"><span class="pre">tau_max</span></code>) and the significance threshold
<img class="math" src="_images/math/2f5aa019312e1bbc969deab8dca8b00f76025404.png" alt="\alpha"/> ( <code class="docutils literal notranslate"><span class="pre">pc_alpha</span></code>).</p>
<p>If a list or None is passed for <code class="docutils literal notranslate"><span class="pre">pc_alpha</span></code>, the significance level is
optimized for every graph across the given <code class="docutils literal notranslate"><span class="pre">pc_alpha</span></code> values using the
score computed in <code class="docutils literal notranslate"><span class="pre">cond_ind_test.get_model_selection_criterion()</span></code>.
Since PCMCIplus outputs not a DAG, but an equivalence class of DAGs,
first one member of this class is computed and then the score is
computed as the average over all models fits for each variable in <code class="docutils literal notranslate"><span class="pre">[0,</span>
<span class="pre">...,</span> <span class="pre">N]</span></code> for that member. The score is the same for all members of the
class.</p>
<p>The maximum time delay depends on the application and should be chosen
according to the maximum causal time lag expected in the complex system.
We recommend a rather large choice that includes peaks in the
<code class="docutils literal notranslate"><span class="pre">get_lagged_dependencies</span></code> function. Another important parameter is
<code class="docutils literal notranslate"><span class="pre">contemp_collider_rule</span></code>. Only if set to <code class="docutils literal notranslate"><span class="pre">majority</span></code> or
<code class="docutils literal notranslate"><span class="pre">conservative''</span> <span class="pre">and</span> <span class="pre">together</span> <span class="pre">with</span> <span class="pre">``conflict_resolution=True</span></code>,
PCMCIplus is fully <em>order independent</em> meaning that the order of the N
variables in the dataframe does not matter. Last, the default option
<code class="docutils literal notranslate"><span class="pre">reset_lagged_links=False</span></code> restricts the detection of lagged causal
links in Step 2 to the significant adjacencies found in Step 1, given by
<img class="math" src="_images/math/6ecffdf6c6b31ddba452a834568233441411465b.png" alt="\widehat{ \mathcal{B}}_t^-( X^j_t)"/>. For
<code class="docutils literal notranslate"><span class="pre">reset_lagged_links=True</span></code>, <em>all</em> lagged links are considered again,
which improves detection power for lagged links, but also leads to
larger runtimes.</p>
<p>Further optional parameters are discussed in [5].</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Deprecated, replaced by link_assumptions</p></li>
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Minimum time lag to test.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em> or </em><em>list of floats</em><em>, </em><em>default: 0.01</em>) – Significance level in algorithm. If a list or None is passed, the
pc_alpha level is optimized for every graph across the given
pc_alpha values ([0.001, 0.005, 0.01, 0.025, 0.05] for None) using
the score computed in cond_ind_test.get_model_selection_criterion().</p></li>
<li><p><strong>contemp_collider_rule</strong> (<em>{'majority'</em><em>, </em><em>'conservative'</em><em>, </em><em>'none'}</em>) – Rule for collider phase to use. See the paper for details. Only
‘majority’ and ‘conservative’ lead to an order-independent
algorithm.</p></li>
<li><p><strong>conflict_resolution</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to mark conflicts in orientation rules. Only for True
this leads to an order-independent algorithm.</p></li>
<li><p><strong>reset_lagged_links</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Restricts the detection of lagged causal links in Step 2 to the
significant adjacencies found in the PC1 algorithm in Step 1. For
True, <em>all</em> lagged links are considered again, which improves
detection power for lagged links, but also leads to larger
runtimes.</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum number of combinations of conditions of current cardinality
to test in PC1 step.</p></li>
<li><p><strong>max_conds_py</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of Y to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px_lagged</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X when X is lagged in MCI
tests. If None is passed, this number is equal to max_conds_px.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'none'</em><em>)</em>) – Correction method, default is Benjamini-Hochberg False Discovery
Rate method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>sepsets</strong> (<em>dictionary</em>) – Separating sets. See paper for details.</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples, only relevant for ‘majority’ and
‘conservative’ rules, see paper for details.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-lpcmci-lpcmci">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.lpcmci</span></code>: LPCMCI<a class="headerlink" href="#tigramite-lpcmci-lpcmci" title="Permalink to this heading">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.lpcmci.LPCMCI">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.lpcmci.</span></span><span class="sig-name descname"><span class="pre">LPCMCI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cond_ind_test</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/lpcmci.html#LPCMCI"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.lpcmci.LPCMCI" title="Permalink to this definition">¶</a></dt>
<dd><p>LPCMCI is an algorithm for causal discovery in large-scale times series that allows for latent confounders and
learns lag-specific causal relationships. The algorithm is introduced and explained in:</p>
<p>[1] Gerhardus, A. &amp; Runge, J. High-recall causal discovery for autocorrelated time series with latent confounders.
Advances in Neural Information Processing Systems, 2020, 33.
<a class="reference external" href="https://proceedings.neurips.cc/paper/2020/hash/94e70705efae423efda1088614128d0b-Abstract.html">https://proceedings.neurips.cc/paper/2020/hash/94e70705efae423efda1088614128d0b-Abstract.html</a></p>
<p>NOTE: This method is still EXPERIMENTAL since the default settings of hyperparameters are still being fine-tuned.
We actually invite feedback on which work best in applications and numerical experiments.
The main function, which applies the algorithm, is ‘run_lpcmci’.</p>
<p>Parameters passed to the constructor:</p>
<ul class="simple">
<li><p>dataframe: Tigramite dataframe object that contains the the time series dataset bold{X}</p></li>
<li><p>cond_ind_test: A conditional independence test object that specifies which conditional independence test CI is to be used</p></li>
<li><p>verbosity: Controls the verbose output self.run_lpcmci() and the function it calls.</p></li>
</ul>
<p>Parameters passed to self.run_lpcmci():
Note: The default values are still being tuned and some parameters might be removed in the future.</p>
<ul>
<li><dl>
<dt>link_assumptions: dict or None</dt><dd><p>Two-level nested dictionary such that link_assumptions[j][(i, lag_i)], where 0 &lt;= j, i &lt;= N-1 (with N the number of component
time series) and -tau_max &lt;= lag_i &lt;= -tau_min, is a string which specifies background knowledge about the link from X^i_{t+lag_i} to
X^j_t. These are the possibilities for this string and the corresponding claim:</p>
<blockquote>
<div><p>‘-?&gt;’   : X^i_{t+lag_i} is an ancestor of X^j_t.
‘–&gt;’   : X^i_{t+lag_i} is an ancestor of X^j_t, and there is a link between X^i_{t+lag_i} and X^j_t
‘&lt;?-’   : Only allowed for lag_i = 0. X^j_t is an ancestor of X^i_t.
‘&lt;–’   : Only allowed for lag_i = 0. X^j_t is an ancestor of X^i_t, and there is a link between X^i_t and X^j_t
‘&lt;?&gt;’   : Neither X^i_{t+lag_i} is an ancestor of X^j_t nor the other way around
‘&lt;-&gt;’   : Neither X^i_{t+lag_i} is an ancestor of X^j_t nor the other way around, and there is a link between X^i_{t+lag_i} and X^j_t
‘o?&gt;’   : X^j_t is not an ancestor of X^i_{t+lag_i} (for lag_i &lt; 0 this background knowledge is (for the default settings of self.run_lpcmci()) imposed automatically)
‘o-&gt;’   : X^j_t is not an ancestor of X^i_{t+lag_i}, and there is a link between X^i_{t+lag_i} and X^j_t
‘&lt;?o’   : Only allowed for lag_i = 0. X^i_t is not an ancestor of X^j_t
‘&lt;-o’   : Only allowed for lag_i = 0. X^i_t is not an ancestor of X^j_t, and there is a link between X^i_t and X^j_t
‘o-o’   : Only allowed for lag_i = 0. There is a link between X^i_t and X^j_t
‘o?o’   : Only allowed for lag_i = 0. No claim is made
‘’      : There is no link between X^i_{t+lag_i} and X^j_t.</p>
</div></blockquote>
<p>Another way to specify the absent link is if the form of the link between (i, lag_i) and (j, 0) is not specified by the dictionary, that is, if either
link_assumptions[j] does not exist or link_assumptions[j] does exist but link_assumptions[j][(i, lag_i)] does
not exist, then the link between (i, lag_i) and (j, 0) is assumed to be absent.</p>
</dd>
</dl>
</li>
<li><p>tau_min: The assumed minimum time lag, i.e., links with a lag smaller
than tau_min are assumed to be absent.</p></li>
<li><p>tau_max: The maximum considered time lag, i.e., the algorithm learns a
DPAG on a time window [t-taumax, t] with tau_max + 1 time steps. It
is <em>not</em> assumed that in the underlying time series DAG there are no
links with a lag larger than tau_max.</p></li>
<li><p>pc_alpha: The significance level of conditional independence tests</p></li>
<li><p>n_preliminary_iterations: Determines the number of iterations in the
preliminary phase of LPCMCI, corresponding to the ‘k’ in LPCMCI(k) in
[1].</p></li>
<li><p>max_cond_px: Consider a pair of variables (X^i_{t-tau}, X^j_t)
with tau &gt; 0. In Algorithm S2 in [1] (here this is
self._run_ancestral_removal_phase()), the algorithm does not test for
conditional independence given subsets of apds_t(X^i_{t-tau}, X^j_t, C
(G)) of cardinality higher than max_cond_px. In Algorithm S3 in [1]
(here this is self._run_non_ancestral_removal_phase()), the algorithm
does not test for conditional independence given subsets of napds_t
(X^i_{t-tau}, X^j_t, C(G)) of cardinality higher than max_cond_px.</p></li>
<li><p>max_p_global: Restricts all conditional independence tests to
conditioning sets with cardinality smaller or equal to max_p_global</p></li>
<li><p>max_p_non_ancestral: Restricts all conditional independence tests in the
second removal phase (here this is self._run_dsep_removal_phase()) to
conditioning sets with cardinality smaller or equal to max_p_global</p></li>
<li><p>max_q_global: For each ordered pair (X^i_{t-tau}, X^j_t) of adjacent
variables and for each cardinality of the conditioning sets test at
most max_q_global many conditioning sets (when summing over all tested
cardinalities more than max_q_global tests may be made)</p></li>
<li><p>max_pds_set: In Algorithm S3 (here this is
self._run_non_ancestral_removal_phase()), the algorithm tests for
conditional independence given subsets of the relevant napds_t sets. If
for a given link the set napds_t(X^j_t, X^i_{t-tau}, C(G)) has more
than max_pds_set many elements (or, if the link is also tested in the
opposite directed, if napds_t(X^i_{t-tau}, X^j_t, C(G)) has more than
max_pds_set elements), this link is not tested.</p></li>
<li><p>prelim_with_collider_rules: If True: As in pseudocode If False: Line 22
of Algorithm S2 in [1] is replaced by line 18 of Algorithm S2 when
Algorithm S2 is called from the preliminary phase (not in the last
application of Algorithm S2 directly before Algorithm S3 is applied)</p></li>
<li><p>parents_of_lagged: If True: As in pseudocode If False: The default
conditioning set is pa(X^j_t, C(G)) rather than pa({X^j_t, X^i_
{t-tau}, C(G)) for tau &gt; 0</p></li>
<li><p>prelim_only: If True, stop after the preliminary phase. Can be used for
detailed performance analysis</p></li>
<li><p>break_once_separated: If True: As in pseudocode If False: The break
commands are removed from Algorithms S2 and S3 in in [1]</p></li>
<li><p>no_non_ancestral_phase: If True, do not execute Algorithm S3. Can be
used for detailed performance analysis</p></li>
<li><p>use_a_pds_t_for_majority: If True: As in pseudocode If False: The search
for separating sets instructed by the majority rule is made given
subsets adj(X^j_t, C(G)) rather than subsets of apds_t(X^j_t, X^i_
{t-tau}, C(G))</p></li>
<li><dl class="simple">
<dt>orient_contemp:</dt><dd><p>If orient_contemp == 1: As in pseudocode of Algorithm S2 in [1]
If orient_contemp == 2: Also orient contemporaneous links in line 18 of Algorithm S2
If orient_comtemp == 0: Also not orient contemporaneous links in line 22 of Algorithm S2</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>update_middle_marks:</dt><dd><p>If True: As in pseudoce of Algorithms S2 and S3 in [1]
If False: The MMR rule is not applied</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>prelim_rules:</dt><dd><p>If prelim_rules == 1: As in pseudocode of Algorithm S2 in [1]
If prelim_rules == 0: Exclude rules R9^prime and R10^prime from line 18 in Algorithm S2</p>
</dd>
</dl>
</li>
<li><p>fix_all_edges_before_final_orientation: When one of max_p_global,
max_p_non_ancestral, max_q_global or max_pds_set is not np.inf, the
algorithm may terminate although not all middle marks are empty. All
orientation rules are nevertheless sound, since the rules always check
for the appropriate middle marks. If
fix_all_edges_before_final_orientation is True, all middle marks are
set to the empty middle mark by force, followed by another application
of the rules.</p></li>
<li><p>auto_first: If True: As in pseudcode of Algorithms S2 and S3 in [1] If
False: Autodependency links are not prioritized even before
contemporaneous links</p></li>
<li><dl class="simple">
<dt>remember_only_parents:</dt><dd><p>If True: As in pseudocode of Algorithm 1
If False: If X^i_{t-tau} has been marked as ancestor of X^j_t at any point of a preliminary iteration but the link between
X^i_{t-tau} and X^j_t was removed later, the link is nevertheless initialized with a tail at X^i_{t-tau} in the re-initialization</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>no_apr:</dt><dd><p>If no_apr == 0: As in pseudcode of Algorithms S2 and S3 in [1]
If no_apr == 1: The APR is not applied by Algorithm S2, except in line 22 of its last call directly before the call of Algorithm S3
If no_apr == 2: The APR is never applied</p>
</dd>
</dl>
</li>
</ul>
<dl class="simple">
<dt>Return value of self.run_lpcmci():</dt><dd><dl class="simple">
<dt>graph<span class="classifier">array of shape (N, N, tau_max+1)</span></dt><dd><p>Resulting DPAG, representing the learned causal relationships.</p>
</dd>
<dt>val_matrix<span class="classifier">array of shape (N, N, tau_max+1)</span></dt><dd><p>Estimated matrix of test statistic values regarding adjacencies.</p>
</dd>
<dt>p_matrix<span class="classifier">array of shape [N, N, tau_max+1]</span></dt><dd><p>Estimated matrix of p-values regarding adjacencies.</p>
</dd>
</dl>
</dd>
</dl>
<p>A note on middle marks: For convenience (to have strings of the same
lengths) we here internally denote the empty middle mark by ‘-’.  For
post-processing purposes all middle marks are set to the empty middle
mark (here ‘-‘).</p>
<p>A note on wildcards: The middle mark wildcard ast and the edge mark
wildcard are here represented as ‘*’’, the edge mark wildcard star
as ‘+’.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.lpcmci.LPCMCI.run_lpcmci">
<span class="sig-name descname"><span class="pre">run_lpcmci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_preliminary_iterations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_cond_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_p_global</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">inf</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_p_non_ancestral</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">inf</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_q_global</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">inf</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_pds_set</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">inf</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prelim_with_collider_rules</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents_of_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prelim_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">break_once_separated</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">no_non_ancestral_phase</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_a_pds_t_for_majority</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">orient_contemp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">update_middle_marks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prelim_rules</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fix_all_edges_before_final_orientation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_first</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remember_only_parents</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">no_apr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/lpcmci.html#LPCMCI.run_lpcmci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.lpcmci.LPCMCI.run_lpcmci" title="Permalink to this definition">¶</a></dt>
<dd><p>Run LPCMCI on the dataset and with the conditional independence test passed to the class constructor and with the
options passed to this function.</p>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-rpcmci-rpcmci">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.rpcmci</span></code>: RPCMCI<a class="headerlink" href="#tigramite-rpcmci-rpcmci" title="Permalink to this heading">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.rpcmci.RPCMCI">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.rpcmci.</span></span><span class="sig-name descname"><span class="pre">RPCMCI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cond_ind_test</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prediction_model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/rpcmci.html#RPCMCI"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.rpcmci.RPCMCI" title="Permalink to this definition">¶</a></dt>
<dd><p>RPCMCI class for extracting causal regimes and the associated graphs from
time series data.</p>
<p class="rubric">Notes</p>
<p>The Regime-PCMCI causal discovery method is described in:</p>
<p>Elena Saggioro, Jana de Wiljes, Marlene Kretschmer, Jakob Runge;
Reconstructing regime-dependent causal relationships from observational
time series. Chaos 1 November 2020; 30 (11): 113115.
<a class="reference external" href="https://doi.org/10.1063/5.0020538">https://doi.org/10.1063/5.0020538</a></p>
<p>The method iterates between two phases –a regime learning phase
(optimization-based) and a causal discovery phase (PCMCI)– to identify
regime dependent causal relationships. A persistent discrete regime
variable is assumed that leads to a finite number of regimes within which
stationarity can be assumed.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – This is the Tigramite dataframe object. It has the attributes
dataframe.values yielding a numpy array of shape ( observations T,
variables N). For RPCMCI the mask will be ignored. You may use the
missing_flag to indicate missing values.</p></li>
<li><p><strong>cond_ind_test</strong> (<em>conditional independence test object</em>) – This can be ParCorr or other classes from
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code> or an external test passed as a
callable. This test can be based on the class
tigramite.independence_tests.CondIndTest.</p></li>
<li><p><strong>prediction_model</strong> (<em>sklearn model object</em>) – For example, sklearn.linear_model.LinearRegression() for a linear
regression model. This should be consistent with cond_ind_test, ie,
use ParCorr() with a linear model and, eg, GPDC() with a
GaussianProcessRegressor model, or CMIknn with NearestNeighbors model.</p></li>
<li><p><strong>seed</strong> (<em>int</em>) – Random seed for annealing step.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Verbose levels -1, 0, 1, …</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.rpcmci.RPCMCI.run_rpcmci">
<span class="sig-name descname"><span class="pre">run_rpcmci</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num_regimes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_transitions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">switch_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_iterations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_anneal</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_jobs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/rpcmci.html#RPCMCI.run_rpcmci"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.rpcmci.RPCMCI.run_rpcmci" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>Run RPCMCI method for extracting causal regimes and the associated graphs from</dt><dd><p>time series data.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>num_regimes</strong> (<em>int</em>) – Number of assumed regimes.</p></li>
<li><p><strong>max_transitions</strong> (<em>int</em>) – Maximum number of transitions within a single regime (persistency parameter).</p></li>
<li><p><strong>switch_thres</strong> (<em>float</em>) – Switch threshold.</p></li>
<li><p><strong>num_iterations</strong> (<em>int</em>) – Optimization iterations.</p></li>
<li><p><strong>max_anneal</strong> (<em>int</em>) – Maximum annealing runs.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Minimum time lag to test.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.2</em><em>)</em>) – Significance level in PCMCI.</p></li>
<li><p><strong>alpha_level</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Significance level in PCMCI at which the p_matrix is thresholded to
get graph.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Number of CPUs to use in joblib parallization. Default n_jobs=-1
uses all available.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>regimes</strong> (<em>array of shape (n_regimes, T)</em>) – One-hot encoded regime variable.</p></li>
<li><p><strong>causal_results</strong> (<em>dictionary</em>) – Contains result of run_pcmci() after convergence.</p></li>
<li><p><strong>diff_g_f</strong> (<em>tuple</em>) – Difference between two consecutive optimizations for all annealings and
the optimal one with minimum objective value (see paper).</p></li>
<li><p><strong>error_free_annealings</strong> (<em>int</em>) – Number of annealings that converged without error.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-jpcmciplus-jpcmciplus">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.jpcmciplus</span></code>: JPCMCIplus<a class="headerlink" href="#tigramite-jpcmciplus-jpcmciplus" title="Permalink to this heading">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.jpcmciplus.</span></span><span class="sig-name descname"><span class="pre">JPCMCIplus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_classification</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus" title="Permalink to this definition">¶</a></dt>
<dd><p>J-PCMCIplus causal discovery for time series datasets from multiple contexts.</p>
<p>This class is based on the PCMCI framework as described in
[1]. JPCMCIplus enables causal discovery for time series data from
different contexts, i.e. datasets, where some of the variables
describing the context might be unobserved. The method is described
in detail in [10]. See the tutorial for guidance in applying the
method.</p>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id5" role="note">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id1">1</a>,<a role="doc-backlink" href="#id2">2</a>,<a role="doc-backlink" href="#id3">3</a>,<a role="doc-backlink" href="#id4">4</a>,<a role="doc-backlink" href="#id7">5</a>,<a role="doc-backlink" href="#id8">6</a>,<a role="doc-backlink" href="#id9">7</a>,<a role="doc-backlink" href="#id25">8</a>,<a role="doc-backlink" href="#id26">9</a>)</span>
<p>J. Runge, P. Nowack, M. Kretschmer, S. Flaxman, D. Sejdinovic,
Detecting and quantifying causal associations in large nonlinear
time series datasets. Sci. Adv. 5, eaau4996
(2019) <a class="reference external" href="https://advances.sciencemag.org/content/5/11/eaau4996">https://advances.sciencemag.org/content/5/11/eaau4996</a></p>
</aside>
<aside class="footnote brackets" id="id6" role="note">
<span class="label"><span class="fn-bracket">[</span>10<span class="fn-bracket">]</span></span>
<p>W. Günther, U. Ninad, J. Runge, Causal discovery for time
series from multiple datasets with latent contexts. UAI 2023</p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>node_classification</strong> (<em>dictionary</em>) – Classification of nodes into system, context, or dummy nodes.
Keys of the dictionary are from {0, …, N-1} where N is the number of nodes.
Options for the values are “system”, “time_context”, “space_context”, “time_dummy”, or “space_dummy”.</p>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.all_parents">
<span class="sig-name descname"><span class="pre">all_parents</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.all_parents" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the conditioning-parents estimated with PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.val_min">
<span class="sig-name descname"><span class="pre">val_min</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.val_min" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form val_min[j][(i, -tau)] = float
containing the minimum test statistic value for each link estimated in
the PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.pval_max">
<span class="sig-name descname"><span class="pre">pval_max</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.pval_max" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form pval_max[j][(i, -tau)] = float containing the maximum
p-value for each link estimated in the PC algorithm.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.iterations">
<span class="sig-name descname"><span class="pre">iterations</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.iterations" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary containing further information on algorithm steps.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.N">
<span class="sig-name descname"><span class="pre">N</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.N" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of variables.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.T">
<span class="sig-name descname"><span class="pre">T</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.T" title="Permalink to this definition">¶</a></dt>
<dd><p>Time series sample length of dataset(s).</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.dummy_parents">
<span class="sig-name descname"><span class="pre">dummy_parents</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.dummy_parents" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the dependence of the system nodes on the dummy nodes.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary or None</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.observed_context_parents">
<span class="sig-name descname"><span class="pre">observed_context_parents</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.observed_context_parents" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the dependence of the system nodes on the observed context nodes.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary or None</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.dummy_ci_test">
<span class="sig-name descname"><span class="pre">dummy_ci_test</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.dummy_ci_test" title="Permalink to this definition">¶</a></dt>
<dd><p>Conditional independence test used to test dependence between system nodes and dummy nodes.
Currently, ParCorr is used with one-hot encoded dummies.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>conditional independence test object</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.mode">
<span class="sig-name descname"><span class="pre">mode</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.mode" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>“system_search” or “context_search” or “dummy_search” (default: “system_search”)</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.time_context_nodes">
<span class="sig-name descname"><span class="pre">time_context_nodes</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.time_context_nodes" title="Permalink to this definition">¶</a></dt>
<dd><p>List with entries from {0, …, N-1} where N is the number of nodes.
This is the list of the temporal context nodes which are assumed to be constant over the different datasets.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.space_context_nodes">
<span class="sig-name descname"><span class="pre">space_context_nodes</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.space_context_nodes" title="Permalink to this definition">¶</a></dt>
<dd><p>List with entries from {0, …, N-1} where N is the number of nodes.
This is the list of the spatial context nodes which are assumed to be constant over time.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.time_dummy">
<span class="sig-name descname"><span class="pre">time_dummy</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.time_dummy" title="Permalink to this definition">¶</a></dt>
<dd><p>Node corresponding to the temporal dummy variable.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int or None (default: None)</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.space_dummy">
<span class="sig-name descname"><span class="pre">space_dummy</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.space_dummy" title="Permalink to this definition">¶</a></dt>
<dd><p>Node corresponding to the spatial dummy variable.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int or None (default: None)</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.system_nodes">
<span class="sig-name descname"><span class="pre">system_nodes</span></span><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.system_nodes" title="Permalink to this definition">¶</a></dt>
<dd><p>List with entries from {0, …, N-1} where N is the number of nodes.
This is the list of the system nodes.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.add_found_context_link_assumptions">
<span class="sig-name descname"><span class="pre">add_found_context_link_assumptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.add_found_context_link_assumptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.add_found_context_link_assumptions" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to add discovered links between system and observed context nodes to link_assumptions.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.assume_exogenous_context">
<span class="sig-name descname"><span class="pre">assume_exogenous_context</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">observed_context_nodes</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.assume_exogenous_context"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.assume_exogenous_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to amend the link_assumptions to ensure that all context-system links are oriented
such that the context variable is the parent.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.clean_link_assumptions">
<span class="sig-name descname"><span class="pre">clean_link_assumptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.clean_link_assumptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.clean_link_assumptions" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to amend the link_assumptions in the following ways
* remove any links where dummy is the child
* remove any lagged links to dummy, and space_context (not to observed time context)
* and system - context links where context is the child
* and any links between spatial and temporal context</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.clean_system_link_assumptions">
<span class="sig-name descname"><span class="pre">clean_system_link_assumptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.clean_system_link_assumptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.clean_system_link_assumptions" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to remove any links to dummy and observed context nodes from link_assumptions.
Add discovered links to contextual parents (from steps 1 and 2) to the link_assumptions.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.discover_dummy_system_links">
<span class="sig-name descname"><span class="pre">discover_dummy_system_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">context_system_results</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lagged_parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset_lagged_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.discover_dummy_system_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.discover_dummy_system_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Step 2 of JPCMCIplus, i.e. discovery of links between observed (time and space) dummy nodes and system nodes
through an application of the skeleton phase of PCMCIplus to this subset of nodes (dummy nodes and
system nodes).
See run_jpcmciplus for a description of the parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>context_system_results</strong> (<em>dictionary</em>) – Output of discover_lagged_and_context_system_links, i.e. lagged and context parents together with the
corresponding estimated test statistic values regarding adjacencies.</p></li>
<li><p><strong>lagged_parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing the conditioning-parents
estimated with PC algorithm.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the estimated dummy parents of the system nodes.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.discover_lagged_context_system_links">
<span class="sig-name descname"><span class="pre">discover_lagged_context_system_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset_lagged_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.discover_lagged_context_system_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.discover_lagged_context_system_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Step 1 of JPCMCIplus, i.e. discovery of links between observed context nodes and system nodes through an
application of the skeleton phase of PCMCIplus to this subset of nodes (observed context nodes and system
nodes).
See run_jpcmciplus for a description of the parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the estimated context parents of the system nodes.</p></li>
<li><p><strong>lagged_parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the conditioning-parents estimated with PC algorithm.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.discover_system_system_links">
<span class="sig-name descname"><span class="pre">discover_system_system_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lagged_context_dummy_parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset_lagged_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.discover_system_system_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.discover_system_system_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Step 4 of JPCMCIplus and orientation phase, i.e. discovery of links between system nodes given the knowledge
about their context parents through an application of PCMCIplus to this subset of nodes (system nodes).
See run_jpcmciplus for a description of the other parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>lagged_context_dummy_parents</strong> (<em>dictionary</em>) – Dictionary containing lagged and (dummy and observed) context parents of the system nodes estimated during
step 1 and step 2 of J-PCMCI+.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>sepset</strong> (<em>dictionary</em>) – Separating sets. See paper for details.</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples, only relevant for ‘majority’ and
‘conservative’ rules, see paper for details.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.remove_dummy_link_assumptions">
<span class="sig-name descname"><span class="pre">remove_dummy_link_assumptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.remove_dummy_link_assumptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.remove_dummy_link_assumptions" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to remove any links to dummy from link_assumptions.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.jpcmciplus.JPCMCIplus.run_jpcmciplus">
<span class="sig-name descname"><span class="pre">run_jpcmciplus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">contemp_collider_rule</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'majority'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_min</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.01</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conflict_resolution</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset_lagged_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_py</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_px_lagged</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fdr_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'none'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/jpcmciplus.html#JPCMCIplus.run_jpcmciplus"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.jpcmciplus.JPCMCIplus.run_jpcmciplus" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs JPCMCIplus time-lagged and contemporaneous causal discovery for time series from multiple contexts.
Method described in [10]:</p>
<blockquote>
<div><p>W. Günther, U. Ninad, J. Runge,
Causal discovery for time series from multiple datasets with latent contexts. UAI 2023</p>
</div></blockquote>
<p class="rubric">Notes</p>
<p>The JPCMCIplus causal discovery method is described in [10], where
also analytical and numerical results are presented. JPCMCIplus can identify the joint causal graph
over multiple datasets containing time series data from different contexts under the standard assumptions
of Causal Sufficiency, Faithfulness and the Markov condition, as well as some background knowledge assumptions.
JPCMCIplus estimates time-lagged and contemporaneous causal links from context to system
variables and in between system variables by a four-step procedure:</p>
<p>1.  <strong>Discovery of supersets of the lagged parents of the system and observed temporal context nodes</strong> by
running the <img class="math" src="_images/math/70934d1a42028f6a8731ad6d32f977bb87341b40.png" alt="PC_1"/> lagged phase on this subset of nodes to obtain <img class="math" src="_images/math/29133806d050a99e9f41db86843ab84d3ffe4cfe.png" alt="\hat{\mathcal{B}}^-_t(X_t^j)"/>.</p>
<p>2.  Next, the <strong>MCI test is run on pairs of system and context nodes conditional on subsets of system
and context</strong>, i.e. perform MCI tests for pairs <img class="math" src="_images/math/610793d48383ce74a3f75cae82f741afb4b15a1f.png" alt="((C^j_{t-\tau}, X^i_t))_{\tau &gt; 0}"/>,
<img class="math" src="_images/math/2aaf85f27254655d2bf003e4ae743175538f32a2.png" alt="(C_t^j, X_t^i)"/>, <img class="math" src="_images/math/5970d3340fdc7a1a2408a0f96f0ca4ccaa2e05c7.png" alt="(X_t^i, C_t^j)"/> for all <img class="math" src="_images/math/5183ea9096ac86aff6e13dd3d4389ae47617b059.png" alt="i,j"/>,</p>
<div class="math">
<p><img src="_images/math/343ec6b8711e2e83b11d1c666c823c15e3076152.png" alt="C_{t-\tau}^i \perp X_t^j | \mathbf{S}, \hat{\mathcal{B}}^-_t(X_t^j)
\setminus \{ C_{t-\tau}^i \}, \hat{\mathcal{B}}^-_{t-\tau}(C_{t-\tau}^i)"/></p>
</div><p>with <img class="math" src="_images/math/f1d8d254182790e09d0e2127717a635ab620c4b3.png" alt="\mathbf{S}"/> being a subset of the contemporaneous adjacencies <img class="math" src="_images/math/002fcaabed0489f553d1c33fb1480262c02bbf5d.png" alt="\mathcal{A}_t(X_t^j)"/> and
<img class="math" src="_images/math/29133806d050a99e9f41db86843ab84d3ffe4cfe.png" alt="\hat{\mathcal{B}}^-_t(X_t^j)"/> are the lagged adjacencies from step one. If <img class="math" src="_images/math/4db5b6e16e06f929ce3f675c5e535d06ffb02ff7.png" alt="C"/> is a
spatial context variable, we only have to test the contemporaneous pairs
<img class="math" src="_images/math/2aaf85f27254655d2bf003e4ae743175538f32a2.png" alt="(C_t^j, X_t^i)"/>, <img class="math" src="_images/math/5970d3340fdc7a1a2408a0f96f0ca4ccaa2e05c7.png" alt="(X_t^i, C_t^j)"/> for all <img class="math" src="_images/math/5183ea9096ac86aff6e13dd3d4389ae47617b059.png" alt="i,j"/>.
If <img class="math" src="_images/math/4dd97b4d2674b7708c46d41c6c012664a2806da0.png" alt="C_t^j"/> and <img class="math" src="_images/math/6ab2d8fa50060307398282bb0365d98a3e7face8.png" alt="X_t^i"/> are conditionally independent, all lagged links between <img class="math" src="_images/math/4dd97b4d2674b7708c46d41c6c012664a2806da0.png" alt="C_t^j"/> and
<img class="math" src="_images/math/707dd16c533765c87784b918b5b28c7b743df715.png" alt="X^j_{t-\tau}"/> are also removed for all <img class="math" src="_images/math/914b2d4b6659b86d3153d5510839dfb254dfc8a3.png" alt="\tau"/>.</p>
<p>3.  <strong>Perform MCI tests on all system-dummy pairs conditional on the superset of lagged links, the discovered
contemporaneous context adjacencies, as well as on subsets of contemporaneous system links</strong>, i.e. test
for <img class="math" src="_images/math/8d6552e42ca019ac82a58b45cd15b5d1caa13c56.png" alt="(D, X_t^i)"/>, <img class="math" src="_images/math/38ab485b0f9e684860df7cece119065d1709ecde.png" alt="(X_t^i, D)"/> for all <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/>, i.e.</p>
<div class="math">
<p><img src="_images/math/f99414a531135c89c3f9f0f2541a28676fb61af6.png" alt="D \perp X_t^j | \mathbf{S}, \hat{\mathcal{B}}^C_t(X_t^j),"/></p>
</div><p>where <img class="math" src="_images/math/8ef6e1b47375edf9ee5c1272b3d0484949cd0a14.png" alt="\mathbf{S} \subset \mathcal{A}_t(X_t^i)"/> and <img class="math" src="_images/math/371dd8b10886065c02a506b1120f2a9a95b3864e.png" alt="\hat{\mathcal{B}}^C_t(X_t^j)"/>
are the lagged and contextual adjacencies found in the previous step.
If <img class="math" src="_images/math/0fcab9067b50b87e868c4fd70f213a086addb964.png" alt="D"/> and <img class="math" src="_images/math/0df0e569fa1d374ca4ebaab68658b71fa6b1e866.png" alt="X_t^j"/> are found to be conditionally independence, links between <img class="math" src="_images/math/0fcab9067b50b87e868c4fd70f213a086addb964.png" alt="D"/> and
<img class="math" src="_images/math/707dd16c533765c87784b918b5b28c7b743df715.png" alt="X^j_{t-\tau}"/> are removed for all <img class="math" src="_images/math/914b2d4b6659b86d3153d5510839dfb254dfc8a3.png" alt="\tau"/>.
By assumption context node is the parent in all system-context links.</p>
<p>4.  Finally, we <strong>perform  MCI tests on all system pairs conditional on discovered lagged, context and dummy
adjacencies, as well as on subsets of contemporaneous system links</strong> and <strong>orientation phase</strong>. In more detail,
we perform MCI test for pairs <img class="math" src="_images/math/b9c77bc33e087d8d416ef250a6bdce03e0f3291f.png" alt="((X^j_{t-\tau}, X_t^i))_{\tau &gt; 0}"/>, <img class="math" src="_images/math/f1d76f63eb859df9073c72ce72af6be86519c006.png" alt="(X_t^i, X_t^j)"/> for all
<img class="math" src="_images/math/f49c62bf4f2fbed05875f0ca49a0c1dbf887c13b.png" alt="i, j"/>, i.e.</p>
<div class="math">
<p><img src="_images/math/e66456f289e2e2476ded91f1a4c5f64f1fd7218b.png" alt="X^i_{t-\tau} \perp X_t^j | \mathbf{S}, \hat{\mathcal{B}}^{CD}_t(X_t^j)
\setminus \{ X_{t-\tau}^i \},\hat{\mathcal{B}}^{CD}_t(X_{t-\tau}^i)"/></p>
</div><p>where <img class="math" src="_images/math/8ef6e1b47375edf9ee5c1272b3d0484949cd0a14.png" alt="\mathbf{S} \subset \mathcal{A}_t(X_t^i)"/> and <img class="math" src="_images/math/0eb451d0d56882f580d23d9206b9beee3b114658.png" alt="\hat{\mathcal{B}}^{CD}_t(X_t^j)"/>
are the lagged, contextual, and dummy adjacencies found in the previous steps.
Finally, all remaining edges (without expert knowledge) are oriented using the PCMCI+ orientation phase while
making use of all triples involving one context or dummy variable and two system variables as in the non-time
series case.</p>
<p>JPCMCIplus can be flexibly combined with any kind of conditional
independence test statistic adapted to the kind of data (continuous
or discrete) and its assumed dependency types. These are available in
<code class="docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>.
See PCMCIplus for a description of the parameters of JPCMCIplus. Also, guidance on best practices for
setting these parameters is given there.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>link_assumptions</strong> (<em>dict</em>) – Dictionary of form {j:{(i, -tau): link_type, …}, …} specifying
assumptions about links. This initializes the graph with entries
graph[i,j,tau] = link_type. For example, graph[i,j,0] = ‘–&gt;’
implies that a directed link from i to j at lag 0 must exist.
Valid link types are ‘o-o’, ‘–&gt;’, ‘&lt;–’. In addition, the middle
mark can be ‘?’ instead of ‘-’. Then ‘-?&gt;’ implies that this link
may not exist, but if it exists, its orientation is ‘–&gt;’. Link
assumptions need to be consistent, i.e., graph[i,j,0] = ‘–&gt;’
requires graph[j,i,0] = ‘&lt;–’ and acyclicity must hold. If a link
does not appear in the dictionary, it is assumed absent. That is,
if link_assumptions is not None, then all links have to be specified
or the links are assumed absent.</p></li>
<li><p><strong>tau_min</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Minimum time lag to test.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em> or </em><em>list of floats</em><em>, </em><em>default: 0.01</em>) – Significance level in algorithm. If a list or None is passed, the
pc_alpha level is optimized for every graph across the given
pc_alpha values ([0.001, 0.005, 0.01, 0.025, 0.05] for None) using
the score computed in cond_ind_test.get_model_selection_criterion().</p></li>
<li><p><strong>contemp_collider_rule</strong> (<em>{'majority'</em><em>, </em><em>'conservative'</em><em>, </em><em>'none'}</em>) – Rule for collider phase to use. See the paper for details. Only
‘majority’ and ‘conservative’ lead to an order-independent
algorithm.</p></li>
<li><p><strong>conflict_resolution</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to mark conflicts in orientation rules. Only for True
this leads to an order-independent algorithm.</p></li>
<li><p><strong>reset_lagged_links</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Restricts the detection of lagged causal links in Step 2 to the
significant adjacencies found in the PC1 algorithm in Step 1. For
True, <em>all</em> lagged links are considered again, which improves
detection power for lagged links, but also leads to larger
runtimes.</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Maximum number of combinations of conditions of current cardinality
to test. Defaults to 1 for PC_1 algorithm. For original PC algorithm
a larger number, such as 10, can be used.</p></li>
<li><p><strong>max_conds_py</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of Y to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X to use in MCI tests. If
None is passed, this number is unrestricted.</p></li>
<li><p><strong>max_conds_px_lagged</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum number of lagged conditions of X when X is lagged in MCI
tests. If None is passed, this number is equal to max_conds_px.</p></li>
<li><p><strong>fdr_method</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'none'</em><em>)</em>) – Correction method, default is Benjamini-Hochberg False Discovery
Rate method.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Resulting causal graph, see description above for interpretation.</p></li>
<li><p><strong>val_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of test statistic values regarding adjacencies.</p></li>
<li><p><strong>p_matrix</strong> (<em>array of shape [N, N, tau_max+1]</em>) – Estimated matrix of p-values regarding adjacencies.</p></li>
<li><p><strong>sepset</strong> (<em>dictionary</em>) – Separating sets. See paper for details.</p></li>
<li><p><strong>ambiguous_triples</strong> (<em>list</em>) – List of ambiguous triples, only relevant for ‘majority’ and
‘conservative’ rules, see paper for details.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-independence-tests-conditional-independence-tests">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.independence_tests</span></code>: Conditional independence tests<a class="headerlink" href="#tigramite-independence-tests-conditional-independence-tests" title="Permalink to this heading">¶</a></h1>
<p>Base class:</p>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.independence_tests_base.</span></span><span class="sig-name descname"><span class="pre">CondIndTest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">42</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">significance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'analytic'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fixed_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sig_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">500</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sig_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">confidence</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.9</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">recycle_residuals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class of conditional independence tests.</p>
<p>Provides useful general functions for different independence tests such as
shuffle significance testing and bootstrap confidence estimation. Also
handles masked samples. Other test classes can inherit from this class.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>seed</strong> (<em>int</em><em>, </em><em>optional</em><em>(</em><em>default = 42</em><em>)</em>) – Seed for RandomState (default_rng)</p></li>
<li><p><strong>mask_type</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default = None</em><em>)</em>) – Must be in {None, ‘y’,’x’,’z’,’xy’,’xz’,’yz’,’xyz’}
Masking mode: Indicators for which variables in the dependence measure
I(X; Y | Z) the samples should be masked. If None, the mask is not used.
Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>significance</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'analytic'</em><em>)</em>) – Type of significance test to use. In this package ‘analytic’,
‘fixed_thres’ and ‘shuffle_test’ are available.</p></li>
<li><p><strong>fixed_thres</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Deprecated.</p></li>
<li><p><strong>sig_samples</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 500</em><em>)</em>) – Number of samples for shuffle significance test.</p></li>
<li><p><strong>sig_blocklength</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Block length for block-shuffle significance test. If None, the
block length is determined from the decay of the autocovariance as
explained in <a class="footnote-reference brackets" href="#id5" id="id7" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p></li>
<li><p><strong>confidence</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Specify type of confidence estimation. If False, numpy.nan is returned.
‘bootstrap’ can be used with any test, for ParCorr also ‘analytic’ is
implemented.</p></li>
<li><p><strong>conf_lev</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.9</em><em>)</em>) – Two-sided confidence interval.</p></li>
<li><p><strong>conf_samples</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 100</em><em>)</em>) – Number of samples for bootstrap.</p></li>
<li><p><strong>conf_blocklength</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Block length for block-bootstrap. If None, the block length is
determined from the decay of the autocovariance as explained in <a class="footnote-reference brackets" href="#id5" id="id8" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p></li>
<li><p><strong>recycle_residuals</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Specifies whether residuals should be stored. This may be faster, but
can cost considerable memory.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_analytic_confidence">
<span class="sig-name descname"><span class="pre">get_analytic_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_analytic_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_analytic_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class assumption that this is not implemented.  Concrete classes
should override when possible.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class assumption that this is not implemented.  Concrete classes
should override when possible.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_bootstrap_confidence">
<span class="sig-name descname"><span class="pre">get_bootstrap_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dependence_measure</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.95</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_bootstrap_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_bootstrap_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform bootstrap confidence interval estimation.</p>
<blockquote>
<div><p>With conf_blocklength &gt; 1 or None a block-bootstrap is performed.</p>
<dl class="simple">
<dt>array<span class="classifier">array-like</span></dt><dd><p>data array with X, Y, Z in rows and observations in columns</p>
</dd>
<dt>xyz<span class="classifier">array of ints</span></dt><dd><p>XYZ identifier array of shape (dim,).</p>
</dd>
<dt>dependence_measure<span class="classifier">function (default = self.get_dependence_measure)</span></dt><dd><p>Dependence measure function must be of form
dependence_measure(array, xyz) and return a numeric value</p>
</dd>
<dt>conf_lev<span class="classifier">float, optional (default: 0.9)</span></dt><dd><p>Two-sided confidence interval.</p>
</dd>
<dt>conf_samples<span class="classifier">int, optional (default: 100)</span></dt><dd><p>Number of samples for bootstrap.</p>
</dd>
<dt>conf_blocklength<span class="classifier">int, optional (default: None)</span></dt><dd><p>Block length for block-bootstrap. If None, the block length is
determined from the decay of the autocovariance as explained in
<a class="footnote-reference brackets" href="#id5" id="id9" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p>
</dd>
</dl>
</div></blockquote>
<dl>
<dt>data_type<span class="classifier">array-like</span></dt><dd><blockquote>
<div><p>Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p>
</div></blockquote>
<dl class="simple">
<dt>verbosity<span class="classifier">int, optional (default: 0)</span></dt><dd><p>Level of verbosity.</p>
</dd>
</dl>
<dl class="simple">
<dt>(conf_lower, conf_upper)<span class="classifier">Tuple of floats</span></dt><dd><p>Upper and lower confidence bound of confidence interval.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_confidence">
<span class="sig-name descname"><span class="pre">get_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform confidence interval estimation.</p>
<blockquote>
<div><p>Calls the dependence measure and confidence test functions. The child
classes can specify a function get_dependence_measure and
get_analytic_confidence or get_bootstrap_confidence. If confidence is
False, (numpy.nan, numpy.nan) is returned.</p>
<dl class="simple">
<dt>X, Y, Z<span class="classifier">list of tuples</span></dt><dd><p>X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index and tau the time lag.</p>
</dd>
<dt>tau_max<span class="classifier">int, optional (default: 0)</span></dt><dd><p>Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p>
</dd>
</dl>
</div></blockquote>
<dl>
<dt>data_type<span class="classifier">array-like</span></dt><dd><blockquote>
<div><p>Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p>
</div></blockquote>
<dl class="simple">
<dt>(conf_lower, conf_upper)<span class="classifier">Tuple of floats</span></dt><dd><p>Upper and lower confidence bound of confidence interval.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_dependence_measure">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract function that all concrete classes must instantiate.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_fixed_thres_significance">
<span class="sig-name descname"><span class="pre">get_fixed_thres_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fixed_thres</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_fixed_thres_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_fixed_thres_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED Returns signficance for thresholding test.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_measure">
<span class="sig-name descname"><span class="pre">get_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Estimate dependence measure.</p>
<blockquote>
<div><p>Calls the dependence measure function. The child classes must specify
a function get_dependence_measure.</p>
<dl class="simple">
<dt>X, Y [, Z]<span class="classifier">list of tuples</span></dt><dd><p>X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index and tau the time lag.</p>
</dd>
<dt>tau_max<span class="classifier">int, optional (default: 0)</span></dt><dd><p>Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p>
</dd>
</dl>
</div></blockquote>
<dl>
<dt>data_type<span class="classifier">array-like</span></dt><dd><blockquote>
<div><p>Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p>
</div></blockquote>
<dl class="simple">
<dt>val<span class="classifier">float</span></dt><dd><p>The test statistic value.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class assumption that this is not implemented.  Concrete classes
should override when possible.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class assumption that this is not implemented.  Concrete classes
should override when possible.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.measure">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract property to store the type of independence test.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.print_info">
<span class="sig-name descname"><span class="pre">print_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.print_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.print_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Print information about the conditional independence test parameters</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.run_test">
<span class="sig-name descname"><span class="pre">run_test</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'2xtau_max'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_or_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.run_test"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.run_test" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform conditional independence test.</p>
<p>Calls the dependence measure and significance test functions. The child
classes must specify a function get_dependence_measure and either or
both functions get_analytic_significance and  get_shuffle_significance.
If recycle_residuals is True, also _get_single_residuals must be
available.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index and tau the time lag.</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index and tau the time lag.</p></li>
<li><p><strong>Z</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index and tau the time lag.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>cut_off</strong> (<em>{'2xtau_max'</em><em>, </em><em>'max_lag'</em><em>, </em><em>'max_lag_or_tau_max'}</em>) – How many samples to cutoff at the beginning. The default is
‘2xtau_max’, which guarantees that MCI tests are all conducted on
the same samples. For modeling, ‘max_lag_or_tau_max’ can be used,
which uses the maximum of tau_max and the conditions, which is
useful to compare multiple models on the same sample.  Last,
‘max_lag’ uses as much samples as possible.</p></li>
<li><p><strong>alpha_or_thres</strong> (<em>float</em><em> (</em><em>optional</em><em>)</em>) – Significance level (if significance=’analytic’ or ‘shuffle_test’) or
threshold (if significance=’fixed_thres’). If given, run_test returns
the test decision dependent=True/False.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val, pval, [dependent]</strong> – The test statistic value and the p-value. If alpha_or_thres is
given, run_test also returns the test decision dependent=True/False.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of floats and bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.run_test_raw">
<span class="sig-name descname"><span class="pre">run_test_raw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_or_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.run_test_raw"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.run_test_raw" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform conditional independence test directly on input arrays x, y, z.</p>
<p>Calls the dependence measure and signficicance test functions. The child
classes must specify a function get_dependence_measure and either or
both functions get_analytic_significance and  get_shuffle_significance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>arrays</em>) – x,y,z are of the form (samples, dimension).</p></li>
<li><p><strong>y</strong> (<em>arrays</em>) – x,y,z are of the form (samples, dimension).</p></li>
<li><p><strong>z</strong> (<em>arrays</em>) – x,y,z are of the form (samples, dimension).</p></li>
<li><p><strong>x_type</strong> (<em>array-like</em>) – data arrays of same shape as x, y and z respectively, which describes whether variables
are continuous or discrete: 0s for continuous variables and
1s for discrete variables</p></li>
<li><p><strong>y_type</strong> (<em>array-like</em>) – data arrays of same shape as x, y and z respectively, which describes whether variables
are continuous or discrete: 0s for continuous variables and
1s for discrete variables</p></li>
<li><p><strong>z_type</strong> (<em>array-like</em>) – data arrays of same shape as x, y and z respectively, which describes whether variables
are continuous or discrete: 0s for continuous variables and
1s for discrete variables</p></li>
<li><p><strong>alpha_or_thres</strong> (<em>float</em><em> (</em><em>optional</em><em>)</em>) – Significance level (if significance=’analytic’ or ‘shuffle_test’) or
threshold (if significance=’fixed_thres’). If given, run_test returns
the test decision dependent=True/False.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val, pval, [dependent]</strong> – The test statistic value and the p-value. If alpha_or_thres is
given, run_test also returns the test decision dependent=True/False.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of floats and bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.set_dataframe">
<span class="sig-name descname"><span class="pre">set_dataframe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.set_dataframe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.set_dataframe" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize and check the dataframe.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>dataframe</strong> (<em>data object</em>) – Set tigramite dataframe object. It must have the attributes
dataframe.values yielding a numpy array of shape (observations T,
variables N) and optionally a mask of the same shape and a missing
values flag.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.independence_tests_base.CondIndTest.set_mask_type">
<span class="sig-name descname"><span class="pre">set_mask_type</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask_type</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/independence_tests_base.html#CondIndTest.set_mask_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.independence_tests_base.CondIndTest.set_mask_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Setter for mask type to ensure that this option does not clash with
recycle_residuals.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>mask_type</strong> (<em>str</em>) – Must be in {None, ‘y’,’x’,’z’,’xy’,’xz’,’yz’,’xyz’}
Masking mode: Indicators for which variables in the dependence measure
I(X; Y | Z) the samples should be masked. If None, the mask is not used.
Explained in tutorial on masking and missing values.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<p>Test statistics:</p>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.parcorr.</span></span><span class="sig-name descname"><span class="pre">ParCorr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr" title="Permalink to this definition">¶</a></dt>
<dd><p>Partial correlation test.</p>
<p>Partial correlation is estimated through linear ordinary least squares (OLS)
regression and a test for non-zero linear Pearson correlation on the
residuals.</p>
<p class="rubric">Notes</p>
<p>To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, first <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/78b6e77cc610bf56f5c64cb6dcc6d6ee49f886f9.png" alt="X &amp; =  Z \beta_X + \epsilon_{X} \\
Y &amp; =  Z \beta_Y + \epsilon_{Y}"/></p>
</div><p>using OLS regression. Then the dependency of the residuals is tested with
the Pearson correlation test.</p>
<div class="math">
<p><img src="_images/math/789735c1db036ea36cd0aa25a3af4b2528ed3abe.png" alt="\rho\left(r_X, r_Y\right)"/></p>
</div><p>For the <code class="docutils literal notranslate"><span class="pre">significance='analytic'</span></code> Student’s-<em>t</em> distribution with
<img class="math" src="_images/math/9c353382eebb42a8a9dec3a426d346d4842bd39d.png" alt="T-D_Z-2"/> degrees of freedom is implemented.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>**kwargs</strong> – Arguments passed on to Parent class CondIndTest.</p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.get_analytic_confidence">
<span class="sig-name descname"><span class="pre">get_analytic_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr.get_analytic_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.get_analytic_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns analytic confidence interval for correlation coefficient.</p>
<p>Based on Student’s t-distribution.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>df</strong> (<em>int</em>) – degrees of freedom of the test</p></li>
<li><p><strong>conf_lev</strong> (<em>float</em>) – Confidence interval, eg, 0.9</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>(conf_lower, conf_upper)</strong> – Upper and lower confidence bound of confidence interval.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of floats</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns analytic p-value from Student’s t-test for the Pearson
correlation coefficient.</p>
<p>Assumes two-sided correlation. If the degrees of freedom are less than
1, numpy.nan is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample length</p></li>
<li><p><strong>dim</strong> (<em>int</em>) – Dimensionality, ie, number of features.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – P-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float or numpy.nan</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return partial correlation.</p>
<p>Estimated as the Pearson correlation of the residuals of a linear
OLS regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Partial correlation coefficient.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">criterion</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'aic'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns model selection criterion modulo constants.</p>
<p>Fits a linear model of the parents to variable j and returns the
score. Here used to determine optimal hyperparameters in PCMCI,
in particular the pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>criterion</strong> (<em>string</em>) – Scoring criterion among AIC, BIC, or corrected AIC.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr.html#ParCorr.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr.ParCorr.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.parcorr.ParCorr.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.robust_parcorr.</span></span><span class="sig-name descname"><span class="pre">RobustParCorr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr" title="Permalink to this definition">¶</a></dt>
<dd><p>Robust partial correlation test based on non-paranormal models.</p>
<p>Partial correlation is estimated through transformation to standard
normal marginals, ordinary least squares (OLS) regression, and a test for
non-zero linear Pearson correlation on the residuals.</p>
<p class="rubric">Notes</p>
<p>To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, firstly, each marginal is transformed to be
standard normally distributed. For that, the transform
<img class="math" src="_images/math/12404a5b5e25ce89d718023e0444f48e6c472c3b.png" alt="\Phi^{-1}\circ\hat{F}"/> is used. Here, <img class="math" src="_images/math/2bf7d59fe2ecd30074d48feb7da561ea838ea61f.png" alt="\Phi^{-1}"/> is the
quantile function of a standard normal distribution and
<img class="math" src="_images/math/f08158476cb55e03cc8643afc1e10a56da446a3a.png" alt="\hat{F}"/> is the empirical distribution function for the respective
marginal.</p>
<p>This idea stems from the literature on nonparanormal models, see:</p>
<ul class="simple">
<li><p>Han Liu, John Lafferty, and Larry Wasserman. The nonparanormal:
semiparametric estimation of high dimensional undirected graphs. J.
Mach. Learn. Res., 10:2295–2328, 2009.</p></li>
<li><p>Han Liu, Fang Han, Ming Yuan, John Lafferty, and Larry Wasserman.
High-dimensional semiparametric Gaussian copula graphical models. Ann.
Statist., 40(4):2293–2326, 2012a.</p></li>
<li><p>Naftali Harris, Mathias Drton. PC Algorithm for Nonparanormal Graphical
Models. Journal of Machine Learning Research, 14: 3365-3383, 2013.</p></li>
</ul>
<p>Afterwards (where Z, X, and Y are now assumed to be transformed to the
standard normal scale):</p>
<p><img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/78b6e77cc610bf56f5c64cb6dcc6d6ee49f886f9.png" alt="X &amp; =  Z \beta_X + \epsilon_{X} \\
Y &amp; =  Z \beta_Y + \epsilon_{Y}"/></p>
</div><p>using OLS regression. Then the dependency of the residuals is tested with
the Pearson correlation test.</p>
<div class="math">
<p><img src="_images/math/789735c1db036ea36cd0aa25a3af4b2528ed3abe.png" alt="\rho\left(r_X, r_Y\right)"/></p>
</div><p>For the <code class="docutils literal notranslate"><span class="pre">significance='analytic'</span></code> Student’s-<em>t</em> distribution with
<img class="math" src="_images/math/9c353382eebb42a8a9dec3a426d346d4842bd39d.png" alt="T-D_Z-2"/> degrees of freedom is implemented.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>**kwargs</strong> – Arguments passed on to Parent class CondIndTest.</p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.get_analytic_confidence">
<span class="sig-name descname"><span class="pre">get_analytic_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.get_analytic_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.get_analytic_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns analytic confidence interval for correlation coefficient.</p>
<p>Based on Student’s t-distribution.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>df</strong> (<em>int</em>) – degrees of freedom of the test</p></li>
<li><p><strong>conf_lev</strong> (<em>float</em>) – Confidence interval, eg, 0.9</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>(conf_lower, conf_upper)</strong> – Upper and lower confidence bound of confidence interval.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of floats</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns analytic p-value from Student’s t-test for the Pearson
correlation coefficient.</p>
<p>Assumes two-sided correlation. If the degrees of freedom are less than
1, numpy.nan is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample length</p></li>
<li><p><strong>dim</strong> (<em>int</em>) – Dimensionality, ie, number of features.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – P-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float or numpy.nan</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return partial correlation.</p>
<p>Marginals are firstly transformed to standard normal scale. Dependence
Measure is then estimated as the Pearson correlation of the residuals
of a linear OLS regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Partial correlation coefficient.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">corrected_aic</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns Akaike’s Information criterion modulo constants.</p>
<p>First of all, each marginal is transformed to the standard normal
scale. For this, each marginal is transformed to the uniform scale
using the empirical distribution function and then, transformed to
the standard normal scale by applying the quantile function of a
standard normal. Afterwards, fits a linear model of the parents to
variable j and returns the score. Leave-one-out cross-validation is
asymptotically equivalent to AIC for ordinary linear regression
models. Here used to determine optimal hyperparameters in
PCMCI(plus), in particular the pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>Firstly, each marginal is transformed to the standard normal scale.
For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.robust_parcorr.RobustParCorr.trafo2normal">
<span class="sig-name descname"><span class="pre">trafo2normal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-05</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/robust_parcorr.html#RobustParCorr.trafo2normal"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.robust_parcorr.RobustParCorr.trafo2normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Transforms input array to standard normal marginals.</p>
<p>For that, the code first transforms to uniform <img class="math" src="_images/math/a7b17d1c3442224393b5a845ae344dbe542593d7.png" alt="[0,1]"/> marginals
using the empirical distribution function, and then transforms to
normal marginals by applying the quantile function of a standard
normal. Assumes x.shape = (dim, T)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>array-like</em>) – Input array.</p></li>
<li><p><strong>thres</strong> (<em>float</em>) – Small number between 0 and 1; after transformation to the uniform
scale, all values that are too close to zero are replaced by thres,
similarly, all values that are too close to one, are replaced by
1-thres. This avoids NaNs.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>normal</strong> – array with normal marginals.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array-like</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.gpdc.</span></span><span class="sig-name descname"><span class="pre">GPDC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">null_dist_filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gp_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC" title="Permalink to this definition">¶</a></dt>
<dd><p>GPDC conditional independence test based on Gaussian processes and distance correlation.</p>
<p>GPDC is based on a Gaussian process (GP) regression and a distance
correlation test on the residuals <a class="footnote-reference brackets" href="#id12" id="id10" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>. GP is estimated with scikit-learn
and allows to flexibly specify kernels and hyperparameters or let them be
optimized automatically. The distance correlation test is implemented with
cython. Here the null distribution is not analytically available, but can be
precomputed with the function generate_and_save_nulldists(…) which saves a
*.npz file containing the null distribution for different sample sizes.
This file can then be supplied as null_dist_filename.</p>
<p class="rubric">Notes</p>
<p>GPDC is based on a Gaussian process (GP) regression and a distance
correlation test on the residuals. Distance correlation is described in
<a class="footnote-reference brackets" href="#id12" id="id11" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>. To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, first <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/db3d34854a6f48587cf5b9a41df90ad1c5e332d6.png" alt="X &amp; =  f_X(Z) + \epsilon_{X} \\
Y &amp; =  f_Y(Z) + \epsilon_{Y}  \\
\epsilon_{X,Y} &amp;\sim \mathcal{N}(0, \sigma^2)"/></p>
</div><p>using GP regression. Here <img class="math" src="_images/math/5406eadc281dbd20de843b0034c8497320dae5cb.png" alt="\sigma^2"/> and the kernel bandwidth are
optimzed using <code class="docutils literal notranslate"><span class="pre">sklearn</span></code>. Then the residuals  are transformed to uniform
marginals yielding <img class="math" src="_images/math/be07aa32325c7a6161c0cef04f9b702054873211.png" alt="r_X,r_Y"/> and their dependency is tested with</p>
<div class="math">
<p><img src="_images/math/5f8c562c89b6bf12d27dc6cdc9dc090f7bb78e9c.png" alt="\mathcal{R}\left(r_X, r_Y\right)"/></p>
</div><p>The null distribution of the distance correlation should be pre-computed.
Otherwise it is computed during runtime.</p>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id12" role="note">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id10">1</a>,<a role="doc-backlink" href="#id11">2</a>,<a role="doc-backlink" href="#id13">3</a>,<a role="doc-backlink" href="#id14">4</a>)</span>
<p>Gabor J. Szekely, Maria L. Rizzo, and Nail K. Bakirov: Measuring and
testing dependence by correlation of distances,
<a class="reference external" href="https://arxiv.org/abs/0803.4101">https://arxiv.org/abs/0803.4101</a></p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>null_dist_filename</strong> (<em>str</em><em>, </em><em>otional</em><em> (</em><em>default: None</em><em>)</em>) – Path to file containing null distribution.</p></li>
<li><p><strong>gp_params</strong> (<em>dictionary</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Dictionary with parameters for <code class="docutils literal notranslate"><span class="pre">GaussianProcessRegressor</span></code>.</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to parent class GaussProcReg.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.generate_and_save_nulldists">
<span class="sig-name descname"><span class="pre">generate_and_save_nulldists</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_sizes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">null_dist_filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.generate_and_save_nulldists"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.generate_and_save_nulldists" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates and saves null distribution for pairwise independence
tests.</p>
<p>Generates the null distribution for different sample sizes. Calls
generate_nulldist. Null dists are saved to disk as
self.null_dist_filename.npz. Also adds the null distributions to
self.gauss_pr.null_dists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sample_sizes</strong> (<em>list</em>) – List of sample sizes.</p></li>
<li><p><strong>null_dist_filename</strong> (<em>str</em>) – Name to save file containing null distributions.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.generate_nulldist">
<span class="sig-name descname"><span class="pre">generate_nulldist</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_to_null_dists</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.generate_nulldist"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.generate_nulldist" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates null distribution for pairwise independence tests.</p>
<p>Generates the null distribution for sample size df. Assumes pairwise
samples transformed to uniform marginals. Uses get_dependence_measure
available in class and generates self.sig_samples random samples. Adds
the null distributions to self.gauss_pr.null_dists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>df</strong> (<em>int</em>) – Degrees of freedom / sample size to generate null distribution for.</p></li>
<li><p><strong>add_to_null_dists</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to add the null dist to the dictionary of null dists or
just return it.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>null_dist</strong> – Only returned,if add_to_null_dists is False.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape [df,]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for the distance correlation coefficient.</p>
<p>The null distribution for necessary degrees of freedom (df) is loaded.
If not available, the null distribution is generated with the function
generate_nulldist(). It is recommended to generate the nulldists for a
wide range of sample sizes beforehand with the function
generate_and_save_nulldists(…). The distance correlation coefficient
is one-sided. If the degrees of freedom are less than 1, numpy.nan is
returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample length</p></li>
<li><p><strong>dim</strong> (<em>int</em>) – Dimensionality, ie, number of features.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float or numpy.nan</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return GPDC measure.</p>
<p>Estimated as the distance correlation of the residuals of a GP
regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – GPDC test statistic.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns log marginal likelihood for GP regression.</p>
<p>Fits a GP model of the parents to variable j and returns the negative
log marginal likelihood as a model selection score. Is used to determine
optimal hyperparameters in PCMCI, in particular the pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc.html#GPDC.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc.GPDC.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.gpdc.GPDC.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.gpdc_torch.</span></span><span class="sig-name descname"><span class="pre">GPDCtorch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">null_dist_filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch" title="Permalink to this definition">¶</a></dt>
<dd><p>GPDC conditional independence test based on Gaussian processes and distance correlation. Here with gpytorch implementation.</p>
<p>GPDC is based on a Gaussian process (GP) regression and a distance
correlation test on the residuals <a class="footnote-reference brackets" href="#id12" id="id13" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>. GP is estimated with gpytorch.
The distance correlation test is implemented with the dcor package available
from pip. Here the null distribution is not analytically available, but can be
precomputed with the function generate_and_save_nulldists(…) which saves a
*.npz file containing the null distribution for different sample sizes.
This file can then be supplied as null_dist_filename.</p>
<p class="rubric">Notes</p>
<p>GPDC is based on a Gaussian process (GP) regression and a distance
correlation test on the residuals. Distance correlation is described in
<a class="footnote-reference brackets" href="#id12" id="id14" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>. To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, first <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/db3d34854a6f48587cf5b9a41df90ad1c5e332d6.png" alt="X &amp; =  f_X(Z) + \epsilon_{X} \\
Y &amp; =  f_Y(Z) + \epsilon_{Y}  \\
\epsilon_{X,Y} &amp;\sim \mathcal{N}(0, \sigma^2)"/></p>
</div><p>using GP regression. Here <img class="math" src="_images/math/5406eadc281dbd20de843b0034c8497320dae5cb.png" alt="\sigma^2"/> and the kernel bandwidth are
optimzed using <code class="docutils literal notranslate"><span class="pre">gpytorch</span></code>. Then the residuals  are transformed to uniform
marginals yielding <img class="math" src="_images/math/be07aa32325c7a6161c0cef04f9b702054873211.png" alt="r_X,r_Y"/> and their dependency is tested with</p>
<div class="math">
<p><img src="_images/math/5f8c562c89b6bf12d27dc6cdc9dc090f7bb78e9c.png" alt="\mathcal{R}\left(r_X, r_Y\right)"/></p>
</div><p>The null distribution of the distance correlation should be pre-computed.
Otherwise it is computed during runtime.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>null_dist_filename</strong> (<em>str</em><em>, </em><em>otional</em><em> (</em><em>default: None</em><em>)</em>) – Path to file containing null distribution.</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to parent class GaussProcRegTorch.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.generate_and_save_nulldists">
<span class="sig-name descname"><span class="pre">generate_and_save_nulldists</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_sizes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">null_dist_filename</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.generate_and_save_nulldists"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.generate_and_save_nulldists" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates and saves null distribution for pairwise independence
tests.</p>
<p>Generates the null distribution for different sample sizes. Calls
generate_nulldist. Null dists are saved to disk as
self.null_dist_filename.npz. Also adds the null distributions to
self.gauss_pr.null_dists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sample_sizes</strong> (<em>list</em>) – List of sample sizes.</p></li>
<li><p><strong>null_dist_filename</strong> (<em>str</em>) – Name to save file containing null distributions.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.generate_nulldist">
<span class="sig-name descname"><span class="pre">generate_nulldist</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_to_null_dists</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.generate_nulldist"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.generate_nulldist" title="Permalink to this definition">¶</a></dt>
<dd><p>Generates null distribution for pairwise independence tests.</p>
<p>Generates the null distribution for sample size df. Assumes pairwise
samples transformed to uniform marginals. Uses get_dependence_measure
available in class and generates self.sig_samples random samples. Adds
the null distributions to self.gauss_pr.null_dists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>df</strong> (<em>int</em>) – Degrees of freedom / sample size to generate null distribution for.</p></li>
<li><p><strong>add_to_null_dists</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to add the null dist to the dictionary of null dists or
just return it.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>null_dist</strong> – Only returned,if add_to_null_dists is False.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape [df,]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for the distance correlation coefficient.</p>
<p>The null distribution for necessary degrees of freedom (df) is loaded.
If not available, the null distribution is generated with the function
generate_nulldist(). It is recommended to generate the nulldists for a
wide range of sample sizes beforehand with the function
generate_and_save_nulldists(…). The distance correlation coefficient
is one-sided. If the degrees of freedom are less than 1, numpy.nan is
returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample length</p></li>
<li><p><strong>dim</strong> (<em>int</em>) – Dimensionality, ie, number of features.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float or numpy.nan</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return GPDC measure.</p>
<p>Estimated as the distance correlation of the residuals of a GP
regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – GPDC test statistic.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns log marginal likelihood for GP regression.</p>
<p>Fits a GP model of the parents to variable j and returns the negative
log marginal likelihood as a model selection score. Is used to determine
optimal hyperparameters in PCMCI, in particular the pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gpdc_torch.html#GPDCtorch.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.gpdc_torch.GPDCtorch.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.gpdc_torch.GPDCtorch.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.cmiknn.</span></span><span class="sig-name descname"><span class="pre">CMIknn</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">knn</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shuffle_neighbors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">significance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'shuffle_test'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'ranks'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_selection_folds</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmiknn.html#CMIknn"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn" title="Permalink to this definition">¶</a></dt>
<dd><p>Conditional mutual information test based on nearest-neighbor estimator.</p>
<p>Conditional mutual information is the most general dependency measure coming
from an information-theoretic framework. It makes no assumptions about the
parametric form of the dependencies by directly estimating the underlying
joint density. The test here is based on the estimator in  S. Frenzel and B.
Pompe, Phys. Rev. Lett. 99, 204101 (2007), combined with a shuffle test to
generate  the distribution under the null hypothesis of independence first
used in <a class="footnote-reference brackets" href="#id16" id="id15" role="doc-noteref"><span class="fn-bracket">[</span>3<span class="fn-bracket">]</span></a>. The knn-estimator is suitable only for variables taking a
continuous range of values. For discrete variables use the CMIsymb class.</p>
<p class="rubric">Notes</p>
<p>CMI is given by</p>
<div class="math">
<p><img src="_images/math/b62df33f46595ed60c51f255186ee346c1fcc0cb.png" alt="I(X;Y|Z) &amp;= \int p(z)  \iint  p(x,y|z) \log
\frac{ p(x,y |z)}{p(x|z)\cdot p(y |z)} \,dx dy dz"/></p>
</div><p>Its knn-estimator is given by</p>
<div class="math">
<p><img src="_images/math/42858b59a7270363c15ca14b0d5fc56d33af1f8a.png" alt="\widehat{I}(X;Y|Z)  &amp;=   \psi (k) + \frac{1}{T} \sum_{t=1}^T
\left[ \psi(k_{Z,t}) - \psi(k_{XZ,t}) - \psi(k_{YZ,t}) \right]"/></p>
</div><p>where <img class="math" src="_images/math/b6c245d487949782a89cab9ee83504a62fdc2337.png" alt="\psi"/> is the Digamma function.  This estimator has as a
parameter the number of nearest-neighbors <img class="math" src="_images/math/9630132210b904754c9ab272b61cb527d12263ca.png" alt="k"/> which determines the
size of hyper-cubes around each (high-dimensional) sample point. Then
<img class="math" src="_images/math/26b09a13f97c2e89eb7687980b95a54839775fc8.png" alt="k_{Z,},k_{XZ},k_{YZ}"/> are the numbers of neighbors in the respective
subspaces.</p>
<p><img class="math" src="_images/math/9630132210b904754c9ab272b61cb527d12263ca.png" alt="k"/> can be viewed as a density smoothing parameter (although it is
data-adaptive unlike fixed-bandwidth estimators). For large <img class="math" src="_images/math/9630132210b904754c9ab272b61cb527d12263ca.png" alt="k"/>, the
underlying dependencies are more smoothed and CMI has a larger bias,
but lower variance, which is more important for significance testing. Note
that the estimated CMI values can be slightly negative while CMI is a non-
negative quantity.</p>
<p>This method requires the scipy.spatial.cKDTree package.</p>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id16" role="note">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id15">3</a><span class="fn-bracket">]</span></span>
<p>J. Runge (2018): Conditional Independence Testing Based on a
Nearest-Neighbor Estimator of Conditional Mutual Information.
In Proceedings of the 21st International Conference on Artificial
Intelligence and Statistics.
<a class="reference external" href="http://proceedings.mlr.press/v84/runge18a.html">http://proceedings.mlr.press/v84/runge18a.html</a></p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>knn</strong> (<em>int</em><em> or </em><em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.2</em><em>)</em>) – Number of nearest-neighbors which determines the size of hyper-cubes
around each (high-dimensional) sample point. If smaller than 1, this is
computed as a fraction of T, hence knn=knn*T. For knn larger or equal to
1, this is the absolute number.</p></li>
<li><p><strong>shuffle_neighbors</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 5</em><em>)</em>) – Number of nearest-neighbors within Z for the shuffle surrogates which
determines the size of hyper-cubes around each (high-dimensional) sample
point.</p></li>
<li><p><strong>transform</strong> (<em>{'ranks'</em><em>, </em><em>'standardize'</em><em>,  </em><em>'uniform'</em><em>, </em><em>False}</em><em>, </em><em>optional</em>) – (default: ‘ranks’)
Whether to transform the array beforehand by standardizing
or transforming to uniform marginals.</p></li>
<li><p><strong>workers</strong> (<em>int</em><em> (</em><em>optional</em><em>, </em><em>default = -1</em><em>)</em>) – Number of workers to use for parallel processing. If -1 is given
all processors are used. Default: -1.</p></li>
<li><p><strong>model_selection_folds</strong> (<em>int</em><em> (</em><em>optional</em><em>, </em><em>default = 3</em><em>)</em>) – Number of folds in cross-validation used in model selection.</p></li>
<li><p><strong>significance</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'shuffle_test'</em><em>)</em>) – Type of significance test to use. For CMIknn only ‘fixed_thres’ and
‘shuffle_test’ are available.</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to parent class CondIndTest.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn.get_conditional_entropy">
<span class="sig-name descname"><span class="pre">get_conditional_entropy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmiknn.html#CMIknn.get_conditional_entropy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn.get_conditional_entropy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the nearest-neighbor conditional entropy estimate of H(X|Y).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,). Here only uses 0 for X and
1 for Y.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Entropy estimate.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmiknn.html#CMIknn.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns CMI estimate as described in Frenzel and Pompe PRL (2007).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Conditional mutual information estimate.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmiknn.html#CMIknn.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a cross-validation-based score for nearest-neighbor estimates.</p>
<p>Fits a nearest-neighbor model of the parents to variable j and returns
the score. The lower, the better the fit. Here used to determine
optimal hyperparameters in PCMCI(pc_alpha or fixed thres).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmiknn.html#CMIknn.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for nearest-neighbor shuffle significance test.</p>
<p>For non-empty Z, overwrites get_shuffle_significance from the parent
class  which is a block shuffle test, which does not preserve
dependencies of X and Y with Z. Here the parameter shuffle_neighbors is
used to permute only those values <img class="math" src="_images/math/c67734af70861b2bd4dedf5c41c9aad231466f84.png" alt="x_i"/> and <img class="math" src="_images/math/ab9afdaf786ce53318d75d81f050af8560822fcd.png" alt="x_j"/> for which
<img class="math" src="_images/math/1a2da53015c9d2f2c52257723f812bf512b6818e.png" alt="z_j"/> is among the nearest niehgbors of <img class="math" src="_images/math/c0d0f97cd9bb4e6571e2689163f9f2989b304f55.png" alt="z_i"/>. If Z is
empty, the block-shuffle test is used.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmiknn.CMIknn.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.cmiknn.CMIknn.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmisymb.CMIsymb">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.cmisymb.</span></span><span class="sig-name descname"><span class="pre">CMIsymb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n_symbs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">significance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'shuffle_test'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sig_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmisymb.html#CMIsymb"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmisymb.CMIsymb" title="Permalink to this definition">¶</a></dt>
<dd><p>Conditional mutual information test for discrete/categorical data.</p>
<p>Conditional mutual information is the most general dependency measure
coming from an information-theoretic framework. It makes no assumptions
about the parametric form of the dependencies by directly estimating the
underlying joint density. The test here is based on directly estimating
the joint distribution assuming symbolic input, combined with a
local shuffle test to generate  the distribution under the null hypothesis of
independence. This estimator is suitable only for discrete variables.
For continuous variables use the CMIknn class and for mixed-variable
datasets the CMIknnMixed class (including mixed-type variables).</p>
<p>Allows for multi-dimensional X, Y.</p>
<p class="rubric">Notes</p>
<p>CMI and its estimator are given by</p>
<div class="math">
<p><img src="_images/math/d226d17c031c4b264fb8f59f953381951cc2e9b4.png" alt="I(X;Y|Z) &amp;= \sum p(z)  \sum \sum  p(x,y|z) \log
\frac{ p(x,y |z)}{p(x|z)\cdot p(y |z)} \,dx dy dz"/></p>
</div><dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n_symbs</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Number of symbols in input data. Should be at least as large as the
maximum array entry + 1. If None, n_symbs is inferred by scipy’s crosstab.</p></li>
<li><p><strong>significance</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'shuffle_test'</em><em>)</em>) – Type of significance test to use. For CMIsymb only ‘fixed_thres’ and
‘shuffle_test’ are available.</p></li>
<li><p><strong>sig_blocklength</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Block length for block-shuffle significance test.</p></li>
<li><p><strong>conf_blocklength</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Block length for block-bootstrap.</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to parent class CondIndTest.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmisymb.CMIsymb.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmisymb.html#CMIsymb.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmisymb.CMIsymb.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns CMI estimate based on contingency table from scipy’s crosstab
to approximate probability mass.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Conditional mutual information estimate.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmisymb.CMIsymb.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/cmisymb.html#CMIsymb.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.cmisymb.CMIsymb.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>Performes a local permutation test: x_i values are only permuted with
those x_j for which z_i = z_j. Samples are drawn without replacement
as much as possible.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for original (unshuffled) estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.cmisymb.CMIsymb.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.cmisymb.CMIsymb.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.oracle_conditional_independence.</span></span><span class="sig-name descname"><span class="pre">OracleCI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">observed_vars</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selection_vars</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">graph</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">graph_is_mag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI" title="Permalink to this definition">¶</a></dt>
<dd><p>Oracle of conditional independence test X _|_ Y | Z given a graph.</p>
<p>Class around link_coeff causal ground truth. X _|_ Y | Z is based on
assessing whether X and Y are d-separated given Z in the graph.</p>
<p>Class can be used just like a Tigramite conditional independence class
(e.g., ParCorr). The main use is for unit testing of PCMCI methods.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape</em><em> [</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>]</em>) – Causal graph.</p></li>
<li><p><strong>links</strong> (<em>dict</em>) – Dictionary of form {0:[(0, -1), …], 1:[…], …}.
Alternatively can also digest {0: [((0, -1), coeff, func)], …}.</p></li>
<li><p><strong>observed_vars</strong> (<em>None</em><em> or </em><em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Subset of keys in links definining which variables are
observed. If None, then all variables are observed.</p></li>
<li><p><strong>selection_vars</strong> (<em>None</em><em> or </em><em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Subset of keys in links definining which variables are
selected (= always conditioned on at every time lag).
If None, then no variables are selected.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.check_shortest_path">
<span class="sig-name descname"><span class="pre">check_shortest_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">starts_with</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ends_with</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">forbidden_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">directed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">only_non_causal_paths</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check_optimality_cond</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimality_cond_des_YM</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimality_cond_Y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_path</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.check_shortest_path"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.check_shortest_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns path between X and Y given Z in the graph.</p>
<p>X, Y, Z are of the form (var, lag) for lag &lt;= 0. D-separation is
based on:</p>
<p>1. Assessing maximum time lag max_lag of last ancestor of any X, Y, Z
with non-blocked (by Z), non-repeating directed path towards X, Y, Z
in the graph. ‘non_repeating’ means that an ancestor X^i_{ t-   au_i}
with link X^i_{t-       au_i} –&gt; X^j_{ t-      au_j} is only included if
X^i_{t’-        au_i} –&gt; X^j_{ t’-     au_j} for t’!=t is not already part of
the ancestors.</p>
<p>2. Using the time series graph truncated at max_lag we then test
d-separation between X and Y conditional on Z using breadth-first
search of non-blocked paths according to d-separation rules including
selection variables.</p>
<p>Optionally only considers paths starting/ending with specific marks)
and makes available the ancestors up to max_lag of X, Y, Z. This may take
a very long time, however.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>list of tuples</em>) – List of variables chosen for testing paths.</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – List of variables chosen for testing paths.</p></li>
<li><p><strong>Z</strong> (<em>list of tuples</em>) – List of variables chosen for testing paths.</p></li>
<li><p><strong>max_lag</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used here to constrain the has_path function to the graph
truncated at max_lag instead of identifying the max_lag from
ancestral search.</p></li>
<li><p><strong>compute_ancestors</strong> (<em>bool</em>) – Whether to also make available the ancestors for X, Y, Z as
self.anc_all_x, self.anc_all_y, and self.anc_all_z, respectively.</p></li>
<li><p><strong>starts_with</strong> (<em>{None</em><em>, </em><em>'tail'</em><em>, </em><em>'arrohead'}</em>) – Whether to only consider paths starting with particular mark at X.</p></li>
<li><p><strong>ends_with</strong> (<em>{None</em><em>, </em><em>'tail'</em><em>, </em><em>'arrohead'}</em>) – Whether to only consider paths ending with particular mark at Y.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>path</strong> – Returns path or False if no path exists.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>list or False</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_confidence">
<span class="sig-name descname"><span class="pre">get_confidence</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.get_confidence"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_confidence" title="Permalink to this definition">¶</a></dt>
<dd><p>For compatibility with PCMCI.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>None</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_graph_from_links">
<span class="sig-name descname"><span class="pre">get_graph_from_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.get_graph_from_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_graph_from_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs graph (DAG or MAG or ADMG) from links, observed_vars,
and selection_vars.</p>
<p>For ADMGs uses the Latent projection operation (Pearl 2009).</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_links_from_graph">
<span class="sig-name descname"><span class="pre">get_links_from_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.get_links_from_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_links_from_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs links_coeffs dictionary, observed_vars,
and selection_vars from graph array (MAG or DAG).</p>
<p>In the case of MAGs, for every &lt;-&gt; or — link further
latent and selection variables, respectively, are added.
This corresponds to a canonical DAG (Richardson Spirtes 2002).</p>
<p>For ADMGs “—” are not supported, but also links of type “+-&gt;”
exist, which corresponds to having both “–&gt;” and “&lt;-&gt;”.</p>
<p>Can be used to evaluate d-separation in MAG/DAGs.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_measure">
<span class="sig-name descname"><span class="pre">get_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.get_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns dependence measure.</p>
<p>Returns 0 if X and Y are d-separated given Z in the graph and 1 else.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>[</strong> (<em>Y</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>Z</strong><strong>]</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – The test statistic value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class assumption that this is not implemented.  Concrete classes
should override when possible.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.run_test">
<span class="sig-name descname"><span class="pre">run_test</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'2xtau_max'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_or_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.run_test"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.run_test" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform oracle conditional independence test.</p>
<p>Calls the d-separation function.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>Z</strong> (<em>list of tuples</em>) – X,Y,Z are of the form [(var, -tau)], where var specifies the
variable index in the observed_vars and tau the time lag.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Not used here.</p></li>
<li><p><strong>cut_off</strong> (<em>{'2xtau_max'</em><em>, </em><em>'max_lag'</em><em>, </em><em>'max_lag_or_tau_max'}</em>) – Not used here.</p></li>
<li><p><strong>alpha_or_thres</strong> (<em>float</em>) – Not used here.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val, pval</strong> – The test statistic value and the p-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of floats</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.oracle_conditional_independence.OracleCI.set_dataframe">
<span class="sig-name descname"><span class="pre">set_dataframe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/oracle_conditional_independence.html#OracleCI.set_dataframe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.oracle_conditional_independence.OracleCI.set_dataframe" title="Permalink to this definition">¶</a></dt>
<dd><p>Dummy function.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.parcorr_mult.</span></span><span class="sig-name descname"><span class="pre">ParCorrMult</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">correlation_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'max_corr'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult" title="Permalink to this definition">¶</a></dt>
<dd><p>Partial correlation test for multivariate X and Y.</p>
<p>Multivariate partial correlation is estimated through ordinary least squares (OLS)
regression and some test for multivariate dependency among the residuals.</p>
<p class="rubric">Notes</p>
<p>To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, first <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/78b6e77cc610bf56f5c64cb6dcc6d6ee49f886f9.png" alt="X &amp; =  Z \beta_X + \epsilon_{X} \\
Y &amp; =  Z \beta_Y + \epsilon_{Y}"/></p>
</div><p>using OLS regression. Then different measures for the dependency among the residuals
can be used. Currently only a test for zero correlation on the maximum of the residuals’
correlation is performed.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>correlation_type</strong> (<em>{'max_corr'}</em>) – Which dependency measure to use on residuals.</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to Parent class CondIndTest.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns analytic p-value depending on correlation_type.</p>
<p>Assumes two-sided correlation. If the degrees of freedom are less than
1, numpy.nan is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>value</strong> (<em>float</em>) – Test statistic value.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample length</p></li>
<li><p><strong>dim</strong> (<em>int</em>) – Dimensionality, ie, number of features.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – P-value.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float or numpy.nan</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return multivariate kernel correlation coefficient.</p>
<p>Estimated as some dependency measure on the
residuals of a linear OLS regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Partial correlation coefficient.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">corrected_aic</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns Akaike’s Information criterion modulo constants.</p>
<p>Fits a linear model of the parents to each variable in j and returns
the average score. Leave-one-out cross-validation is asymptotically
equivalent to AIC for ordinary linear regression models. Here used to
determine optimal hyperparameters in PCMCI, in particular the
pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_mult.ParCorrMult.mult_corr">
<span class="sig-name descname"><span class="pre">mult_corr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standardize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_mult.html#ParCorrMult.mult_corr"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_mult.ParCorrMult.mult_corr" title="Permalink to this definition">¶</a></dt>
<dd><p>Return multivariate dependency measure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>standardize</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to standardize the array beforehand. Must be used for
partial correlation.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Multivariate dependency measure.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.gsquared.Gsquared">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.gsquared.</span></span><span class="sig-name descname"><span class="pre">Gsquared</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n_symbs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gsquared.html#Gsquared"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gsquared.Gsquared" title="Permalink to this definition">¶</a></dt>
<dd><p>G-squared conditional independence test for categorical data.</p>
<p>Uses Chi2 as the null distribution and the method from <a class="footnote-reference brackets" href="#id18" id="id17" role="doc-noteref"><span class="fn-bracket">[</span>7<span class="fn-bracket">]</span></a> to
adjust the degrees of freedom. Valid only asymptotically, recommended are
above 1000-2000 samples (depends on data). For smaller sample sizes use the
CMIsymb class which includes a local permutation test.</p>
<p>Assumes one-dimensional X, Y.</p>
<p>This method requires the scipy.stats package.</p>
<p class="rubric">Notes</p>
<p>The general formula is</p>
<div class="math">
<p><img src="_images/math/93468ec117fc04c2589757eb61fc11c15d27bc1b.png" alt="G(X;Y|Z) &amp;= 2 n \sum p(z)  \sum \sum  p(x,y|z) \log
\frac{ p(x,y |z)}{p(x|z)\cdot p(y |z)}"/></p>
</div><p>where <img class="math" src="_images/math/5a939c5280da7202ca4531f175a7780ad5e1f80a.png" alt="n"/> is the sample size. This is simply <img class="math" src="_images/math/88da5b28f5e08d9d8ed693d334e710f4adadbcfd.png" alt="2 n CMI(X;Y|Z)"/>.</p>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id18" role="note">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id17">7</a><span class="fn-bracket">]</span></span>
<p>Bishop, Y.M.M., Fienberg, S.E. and Holland, P.W. (1975) Discrete
Multivariate Analysis: Theory and Practice. MIT Press, Cambridge.</p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n_symbs</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Number of symbols in input data. Should be at least as large as the
maximum array entry + 1. If None, n_symbs is inferred by scipy’s crosstab</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to parent class CondIndTest.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gsquared.Gsquared.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gsquared.html#Gsquared.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gsquared.Gsquared.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the p_value of test statistic value ‘value’, according to a
chi-square distribution with ‘dof’ degrees of freedom.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.gsquared.Gsquared.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/gsquared.html#Gsquared.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.gsquared.Gsquared.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns Gsquared/G-test test statistic.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – G-squared estimate.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.gsquared.Gsquared.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.gsquared.Gsquared.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_wls.ParCorrWLS">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.parcorr_wls.</span></span><span class="sig-name descname"><span class="pre">ParCorrWLS</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">gt_std_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expert_knowledge</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'time-dependent</span> <span class="pre">heteroskedasticity'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">window_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">robustify</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_wls.html#ParCorrWLS"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_wls.ParCorrWLS" title="Permalink to this definition">¶</a></dt>
<dd><p>Weighted partial correlation test.</p>
<p>Partial correlation is estimated through linear weighted least squares (WLS)
regression and a test for non-zero linear Pearson correlation on the
residuals.
Either the variances, i.e. weights, are known, or they can be estimated using non-parametric regression
(using k nearest neighbour).</p>
<p class="rubric">Notes</p>
<p>To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, first <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/> is regressed out from
<img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> and <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> assuming the  model</p>
<div class="math">
<p><img src="_images/math/78b6e77cc610bf56f5c64cb6dcc6d6ee49f886f9.png" alt="X &amp; =  Z \beta_X + \epsilon_{X} \\
Y &amp; =  Z \beta_Y + \epsilon_{Y}"/></p>
</div><p>using WLS regression. Here, we do not assume homoskedasticity of the error terms.
Then the dependency of the residuals is tested with
the Pearson correlation test.</p>
<div class="math">
<p><img src="_images/math/789735c1db036ea36cd0aa25a3af4b2528ed3abe.png" alt="\rho\left(r_X, r_Y\right)"/></p>
</div><p>For the <code class="docutils literal notranslate"><span class="pre">significance='analytic'</span></code> Student’s-<em>t</em> distribution with
<img class="math" src="_images/math/9c353382eebb42a8a9dec3a426d346d4842bd39d.png" alt="T-D_Z-2"/> degrees of freedom is implemented.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>gt_std_matrix</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Standard deviations of the noise of shape (T, nb_nodes)</p></li>
<li><p><strong>expert_knowledge</strong> (<em>string</em><em> or </em><em>dict</em><em> (</em><em>default: time-dependent heteroskedasticity</em><em>)</em>) – Either string “time-dependent heteroskedasticity” meaning that every variable only has time-dependent
heteroskedasticity, or string “homoskedasticity” where we assume homoskedasticity for all variables, or
dictionary containing expert knowledge about heteroskedastic relationships as list of tuples or strings.</p></li>
<li><p><strong>window_size</strong> (<em>int</em><em> (</em><em>default: 10</em><em>)</em>) – Number of nearest neighbours that we are using for estimating the variance function.</p></li>
<li><p><strong>robustify</strong> (<em>bool</em><em> (</em><em>default: False</em><em>)</em>) – Indicates whether the robust partial correlation test should be used, i.e. whether the data should be
transformed to normal marginals before testing</p></li>
<li><p><strong>**kwargs</strong> – Arguments passed on to Parent class ParCorr.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_wls.html#ParCorrWLS.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Return partial correlation.</p>
<p>Estimated as the Pearson correlation of the residuals of a linear
OLS regression.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – Partial correlation coefficient.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_model_selection_criterion">
<span class="sig-name descname"><span class="pre">get_model_selection_criterion</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">corrected_aic</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_wls.html#ParCorrWLS.get_model_selection_criterion"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_model_selection_criterion" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns Akaike’s Information criterion modulo constants.</p>
<p>Fits a linear model of the parents to variable j and returns the
score. Leave-one-out cross-validation is asymptotically equivalent to
AIC for ordinary linear regression models. Here used to determine
optimal hyperparameters in PCMCI, in particular the pc_alpha value.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of target variable in data array.</p></li>
<li><p><strong>parents</strong> (<em>list</em>) – List of form [(0, -1), (3, -2), …] containing parents.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X, Z, all have the same sample size.</p></li>
<li><p><strong>Returns</strong> – </p></li>
<li><p><strong>score</strong> (<em>float</em>) – Model score.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_shuffle_significance">
<span class="sig-name descname"><span class="pre">get_shuffle_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_null_dist</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/parcorr_wls.html#ParCorrWLS.get_shuffle_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.parcorr_wls.ParCorrWLS.get_shuffle_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns p-value for shuffle significance test.</p>
<p>For residual-based test statistics only the residuals are shuffled.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>value</strong> (<em>number</em>) – Value of test statistic for unshuffled estimate.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>pval</strong> – p-value</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.independence_tests.regressionCI.RegressionCI">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.independence_tests.regressionCI.</span></span><span class="sig-name descname"><span class="pre">RegressionCI</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/regressionCI.html#RegressionCI"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.regressionCI.RegressionCI" title="Permalink to this definition">¶</a></dt>
<dd><p>Flexible parametric conditional independence tests for continuous, categorical, or mixed data.</p>
<p>Assumes one-dimensional X, Y.</p>
<p class="rubric">Notes</p>
<p>To test <img class="math" src="_images/math/667eda4bf3d5ce33b6cc785cadfef79bb95741ca.png" alt="X \perp Y | Z"/>, the regressions Y|XZ vs Y|Z, or, depending
on certain criteria, X|YZ vs X|Z are compared. For that, the notion of
the deviance is employed. If the fits of the respective regressions do
not differ significantly (measured using the deviance), the null
hypotheses of conditional independence is “accepted”. This approach
assumes that X and Y are univariate, and Z can be either empty,
univariate or multivariate. Moreover, this approach works for all
combinations of “discrete” and “continuous” X, Y and respective columns
of Z; depending on the case, linear regression or multinomial regression
is employed.</p>
<p>Assumes one-dimensional X, Y.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>**kwargs</strong> – Arguments passed on to parent class CondIndTest.</p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.regressionCI.RegressionCI.get_analytic_significance">
<span class="sig-name descname"><span class="pre">get_analytic_significance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/regressionCI.html#RegressionCI.get_analytic_significance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.regressionCI.RegressionCI.get_analytic_significance" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the p_value of test statistic.</p>
<p>According to a chi-square distribution with ‘dof’ degrees of freedom.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.regressionCI.RegressionCI.get_dependence_measure">
<span class="sig-name descname"><span class="pre">get_dependence_measure</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/regressionCI.html#RegressionCI.get_dependence_measure"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.regressionCI.RegressionCI.get_dependence_measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns test statistic.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns.</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>data_type</strong> (<em>array-like</em>) – array of same shape as array which describes whether samples
are continuous or discrete: 0s for continuous and
1s for discrete</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val</strong> – test estimate.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tigramite.independence_tests.regressionCI.RegressionCI.measure">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">measure</span></span><a class="headerlink" href="#tigramite.independence_tests.regressionCI.RegressionCI.measure" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete property to return the measure of the independence test</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.independence_tests.regressionCI.RegressionCI.set_dataframe">
<span class="sig-name descname"><span class="pre">set_dataframe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/independence_tests/regressionCI.html#RegressionCI.set_dataframe"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.independence_tests.regressionCI.RegressionCI.set_dataframe" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize and check the dataframe.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>dataframe</strong> (<em>data object</em>) – Set tigramite dataframe object. It must have the attributes
dataframe.values yielding a numpy array of shape (observations T,
variables N) and optionally a mask of the same shape and a missing
values flag.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-causal-effects-causal-effect-analysis">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.causal_effects</span></code>: Causal Effect analysis<a class="headerlink" href="#tigramite-causal-effects-causal-effect-analysis" title="Permalink to this heading">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.causal_effects.</span></span><span class="sig-name descname"><span class="pre">CausalEffects</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">graph_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">S</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hidden_variables</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check_SM_overlap</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects" title="Permalink to this definition">¶</a></dt>
<dd><p>Causal effect estimation.</p>
<p>Methods for the estimation of linear or non-parametric causal effects
between (potentially multivariate) X and Y (potentially conditional
on S) by (generalized) backdoor adjustment. Various graph types are
supported, also including hidden variables.</p>
<p>Linear and non-parametric estimators are based on sklearn. For the
linear case without hidden variables also an efficient estimation
based on Wright’s path coefficients is available. This estimator
also allows to estimate mediation effects.</p>
<p>See the corresponding paper <a class="footnote-reference brackets" href="#id20" id="id19" role="doc-noteref"><span class="fn-bracket">[</span>6<span class="fn-bracket">]</span></a> and tigramite tutorial for an
in-depth introduction.</p>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id20" role="note">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id19">6</a><span class="fn-bracket">]</span></span>
<p>J. Runge, Necessary and sufficient graphical conditions for
optimal adjustment sets in causal graphical models with
hidden variables, Advances in Neural Information Processing
Systems, 2021, 34
<a class="reference external" href="https://proceedings.neurips.cc/paper/2021/hash/8485ae387a981d783f8764e508151cd9-Abstract.html">https://proceedings.neurips.cc/paper/2021/hash/8485ae387a981d783f8764e508151cd9-Abstract.html</a></p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>array of either shape</em><em> [</em><em>N</em><em>, </em><em>N</em><em>]</em><em>, </em><em>[</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>]</em><em>, or </em><em>[</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>, </em><em>tau_max+1</em><em>]</em>) – Different graph types are supported, see tutorial.</p></li>
<li><p><strong>X</strong> (<em>list of tuples</em>) – List of tuples [(i, -tau), …] containing cause variables.</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – List of tuples [(j, 0), …] containing effect variables.</p></li>
<li><p><strong>S</strong> (<em>list of tuples</em>) – List of tuples [(i, -tau), …] containing conditioned variables.</p></li>
<li><p><strong>graph_type</strong> (<em>str</em>) – Type of graph.</p></li>
<li><p><strong>hidden_variables</strong> (<em>list of tuples</em>) – Hidden variables in format [(i, -tau), …]. The internal graph is
constructed by a latent projection.</p></li>
<li><p><strong>check_SM_overlap</strong> (<em>bool</em>) – Whether to check whether S overlaps with M.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.check_XYS_paths">
<span class="sig-name descname"><span class="pre">check_XYS_paths</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.check_XYS_paths"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.check_XYS_paths" title="Permalink to this definition">¶</a></dt>
<dd><p>Check whether one can remove nodes from X and Y with no proper causal paths.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>X, Y</strong></p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>cleaned lists of X and Y with irrelevant nodes removed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.check_optimality">
<span class="sig-name descname"><span class="pre">check_optimality</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.check_optimality"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.check_optimality" title="Permalink to this definition">¶</a></dt>
<dd><p>Check whether optimal adjustment set exists according to Thm. 3 in Runge NeurIPS 2021.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>optimality</strong> – Returns True if an optimal adjustment set exists, otherwise False.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.fit_bootstrap_of">
<span class="sig-name descname"><span class="pre">fit_bootstrap_of</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">method</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method_args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boot_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boot_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.fit_bootstrap_of"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.fit_bootstrap_of" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs chosen method on bootstrap samples drawn from DataFrame.</p>
<p>Bootstraps for tau=0 are drawn from [max_lag, …, T] and all lagged
variables constructed in DataFrame.construct_array are consistently
shifted with respect to this bootsrap sample to ensure that lagged
relations in the bootstrap sample are preserved.</p>
<p>This function fits the models, predict_bootstrap_of can then be used
to get confidence intervals for the effect of interventions.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>method</strong> (<em>str</em>) – Chosen method among valid functions in this class.</p></li>
<li><p><strong>method_args</strong> (<em>dict</em>) – Arguments passed to method.</p></li>
<li><p><strong>boot_samples</strong> (<em>int</em>) – Number of bootstrap samples to draw.</p></li>
<li><p><strong>boot_blocklength</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Block length for block-bootstrap.</p></li>
<li><p><strong>seed</strong> (<em>int</em><em>, </em><em>optional</em><em>(</em><em>default = None</em><em>)</em>) – Seed for RandomState (default_rng)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.fit_total_effect">
<span class="sig-name descname"><span class="pre">fit_total_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">estimator</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adjustment_set</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'optimal'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conditional_estimator</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore_identifiability</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.fit_total_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.fit_total_effect" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>Returns a fitted model for the total causal effect of X on Y</dt><dd><p>conditional on S.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>estimator</strong> (<em>sklearn model object</em>) – For example, sklearn.linear_model.LinearRegression() for a linear
regression model.</p></li>
<li><p><strong>adjustment_set</strong> (<em>str</em><em> or </em><em>list of tuples</em>) – If ‘optimal’ the Oset is used, if ‘minimized_optimal’ the minimized Oset,
and if ‘colliders_minimized_optimal’, the colliders-minimized Oset.
If a list of tuples is passed, this set is used.</p></li>
<li><p><strong>conditional_estimator</strong> (<em>sklearn model object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used to fit conditional causal effects in nested regression.
If None, the same model as for estimator is used.</p></li>
<li><p><strong>data_transform</strong> (<em>sklearn preprocessing object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used to transform data prior to fitting. For example,
sklearn.preprocessing.StandardScaler for simple standardization. The
fitted parameters are stored.</p></li>
<li><p><strong>mask_type</strong> (<em>{None</em><em>, </em><em>'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>ignore_identifiability</strong> (<em>bool</em>) – Only applies to adjustment sets supplied by user. Ignores if that
set leads to a non-identifiable effect.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.fit_wright_effect">
<span class="sig-name descname"><span class="pre">fit_wright_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mediation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'parents'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">links_coeffs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.fit_wright_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.fit_wright_effect" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>Returns a fitted model for the total or mediated causal effect of X on Y</dt><dd><p>potentially through mediator variables.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>mediation</strong> (<em>None</em><em>, </em><em>'direct'</em><em>, or </em><em>list of tuples</em>) – If None, total effect is estimated, if ‘direct’ then only the direct effect is estimated,
else only those causal paths are considerd that pass at least through one of these mediator nodes.</p></li>
<li><p><strong>method</strong> (<em>{'parents'</em><em>, </em><em>'links_coeffs'</em><em>, </em><em>'optimal'}</em>) – Method to use for estimating Wright’s path coefficients. If ‘optimal’,
the Oset is used, if ‘links_coeffs’, the coefficients in links_coeffs are used,
if ‘parents’, the parents are used (only valid for DAGs).</p></li>
<li><p><strong>links_coeffs</strong> (<em>dict</em>) – Only used if method = ‘links_coeffs’.
Dictionary of format: {0:[((i, -tau), coeff),…], 1:[…],
…} for all variables where i must be in [0..N-1] and tau &gt;= 0 with
number of variables N. coeff must be a float.</p></li>
<li><p><strong>data_transform</strong> (<em>None</em>) – Not implemented for Wright estimator. Complicated for missing samples.</p></li>
<li><p><strong>mask_type</strong> (<em>{None</em><em>, </em><em>'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.get_dict_from_graph">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_dict_from_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parents_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.get_dict_from_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.get_dict_from_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to convert graph to dictionary of links.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>array of shape</em><em> (</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>)</em>) – Matrix format of graph in string format.</p></li>
<li><p><strong>parents_only</strong> (<em>bool</em>) – Whether to only return parents (’–&gt;’ in graph)</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>links</strong> – Dictionary of form {0:{(0, -1): o-o, …}, 1:{…}, …}.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.get_graph_from_dict">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_graph_from_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.get_graph_from_dict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.get_graph_from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to convert dictionary of links to graph array format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>links</strong> (<em>dict</em>) – Dictionary of form {0:[((0, -1), coeff, func), …], 1:[…], …}.
Also format {0:[(0, -1), …], 1:[…], …} is allowed.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum lag. If None, the maximum lag in links is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>graph</strong> – Matrix format of graph with 1 for true links and 0 else.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N, N, tau_max+1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.get_mediators">
<span class="sig-name descname"><span class="pre">get_mediators</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.get_mediators"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.get_mediators" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns mediator variables on proper causal paths.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start</strong> (<em>set</em>) – Set of start nodes.</p></li>
<li><p><strong>end</strong> (<em>set</em>) – Set of end nodes.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>mediators</strong> – Mediators on causal paths from start to end.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>set</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.get_optimal_set">
<span class="sig-name descname"><span class="pre">get_optimal_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">alternative_conditions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minimize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_separate_sets</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.get_optimal_set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.get_optimal_set" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns optimal adjustment set.</p>
<p>See Runge NeurIPS 2021.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>alternative_conditions</strong> (<em>set of tuples</em>) – Used only internally in optimality theorem. If None, self.S is used.</p></li>
<li><p><strong>minimize</strong> (<em>{False</em><em>, </em><em>True</em><em>, </em><em>'colliders_only'}</em>) – Minimize optimal set. If True, minimize such that no subset
can be removed without making it invalid. If ‘colliders_only’,
only colliders are minimized.</p></li>
<li><p><strong>return_separate_sets</strong> (<em>bool</em>) – Whether to return tuple of parents, colliders, collider_parents, and S.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>Oset_S</strong> – Returns optimal adjustment set if a valid set exists, otherwise False.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>False or list or tuple of lists</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.predict_bootstrap_of">
<span class="sig-name descname"><span class="pre">predict_bootstrap_of</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">method</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method_args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.9</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_individual_bootstrap_results</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.predict_bootstrap_of"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.predict_bootstrap_of" title="Permalink to this definition">¶</a></dt>
<dd><p>Predicts with fitted bootstraps.</p>
<p>To be used after fitting with fit_bootstrap_of. Only uses the
expected values of the predict function, not potential other output.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>method</strong> (<em>str</em>) – Chosen method among valid functions in this class.</p></li>
<li><p><strong>method_args</strong> (<em>dict</em>) – Arguments passed to method.</p></li>
<li><p><strong>conf_lev</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.9</em><em>)</em>) – Two-sided confidence interval.</p></li>
<li><p><strong>return_individual_bootstrap_results</strong> (<em>bool</em>) – Returns the individual bootstrap predictions.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>confidence_intervals</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>numpy array</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.predict_total_effect">
<span class="sig-name descname"><span class="pre">predict_total_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">intervention_data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conditions_data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_further_pred_results=False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aggregation_func=&lt;function</span> <span class="pre">mean&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transform_interventions_and_prediction=False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.predict_total_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.predict_total_effect" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict effect of intervention with fitted model.</p>
<p>Uses the model.predict() function of the sklearn model.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>intervention_data</strong> (<em>numpy array</em>) – Numpy array of shape (time, len(X)) that contains the do(X) values.</p></li>
<li><p><strong>conditions_data</strong> (<em>data object</em><em>, </em><em>optional</em>) – Numpy array of shape (time, len(S)) that contains the S=s values.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function.</p></li>
<li><p><strong>return_further_pred_results</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – In case the predictor class returns more than just the expected value,
the entire results can be returned.</p></li>
<li><p><strong>aggregation_func</strong> (<em>callable</em>) – Callable applied to output of ‘predict’. Default is ‘np.mean’.</p></li>
<li><p><strong>transform_interventions_and_prediction</strong> (<em>bool</em><em> (</em><em>default: False</em><em>)</em>) – Whether to perform the inverse data_transform on prediction results.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>Results from prediction</strong> (<em>an array of shape  (time, len(Y)).</em>)</p></li>
<li><p><em>If estimate_confidence = True, then a tuple is returned.</em></p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.causal_effects.CausalEffects.predict_wright_effect">
<span class="sig-name descname"><span class="pre">predict_wright_effect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">intervention_data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/causal_effects.html#CausalEffects.predict_wright_effect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.causal_effects.CausalEffects.predict_wright_effect" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict linear effect of intervention with fitted Wright-model.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>intervention_data</strong> (<em>numpy array</em>) – Numpy array of shape (time, len(X)) that contains the do(X) values.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>Results from prediction</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>an array of shape  (time, len(Y)).</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="tigramite-models-time-series-modeling-mediation-and-prediction">
<h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.models</span></code>: Time series modeling, mediation, and prediction<a class="headerlink" href="#tigramite-models-time-series-modeling-mediation-and-prediction" title="Permalink to this heading">¶</a></h1>
<p>Base class:</p>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.models.Models">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.models.</span></span><span class="sig-name descname"><span class="pre">Models</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conditional_model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for time series models.</p>
<p>Allows to fit any model from sklearn to the parents of a target variable.
Also takes care of missing values, masking and preprocessing. If the
target variable is multivariate, a model that supports multi-output
regression must be used. Note that
sklearn.multioutput.MultiOutputRegressor allows to extend single-output
models.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>model</strong> (<em>sklearn model object</em>) – For example, sklearn.linear_model.LinearRegression() for a linear
regression model.</p></li>
<li><p><strong>conditional_model</strong> (<em>sklearn model object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used to fit conditional causal effects in nested regression.
If None, model is used.</p></li>
<li><p><strong>data_transform</strong> (<em>sklearn preprocessing object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used to transform data prior to fitting. For example,
sklearn.preprocessing.StandardScaler for simple standardization. The
fitted parameters are stored. Note that the inverse_transform is then
applied to the predicted data.</p></li>
<li><p><strong>mask_type</strong> (<em>{None</em><em>, </em><em>'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.fit_full_model">
<span class="sig-name descname"><span class="pre">fit_full_model</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all_parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_variables=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off='max_lag_or_tau_max'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">empty_predictors_function=&lt;function</span> <span class="pre">mean&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_data=False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.fit_full_model"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.fit_full_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit time series model.</p>
<p>For each variable in selected_variables, the sklearn model is fitted
with <img class="math" src="_images/math/1b5e577d6216dca3af7d87aa122a0b9b360d6cb3.png" alt="y"/> given by the target variable, and <img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> given by its
parents. The fitted model class is returned for later use.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>all_parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, 0), …], 1:[], …} containing
the parents estimated with PCMCI.</p></li>
<li><p><strong>selected_variables</strong> (<em>list of integers</em><em>, </em><em>optional</em><em> (</em><em>default: range</em><em>(</em><em>N</em><em>)</em><em>)</em>) – Specify to estimate parents only for selected variables. If None is
passed, parents are estimated for all variables.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum time lag. If None, the maximum lag in all_parents is used.</p></li>
<li><p><strong>cut_off</strong> (<em>{'max_lag_or_tau_max'</em><em>, </em><em>'2xtau_max'</em><em>, </em><em>'max_lag'}</em>) – How many samples to cutoff at the beginning. The default is
‘max_lag_or_tau_max’, which uses the maximum of tau_max and the
conditions. This is useful to compare multiple models on the same
sample. Other options are ‘2xtau_max’, which guarantees that MCI
tests are all conducted on the same samples. Last, ‘max_lag’ uses
as much samples as possible.</p></li>
<li><p><strong>empty_predictors_function</strong> (<em>function</em>) – Function to apply to y if no predictors are given.</p></li>
<li><p><strong>return_data</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to save the data array.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>fit_results</strong> – Returns the sklearn model after fitting. Also returns the data
transformation parameters.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary of sklearn model objects for each variable</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.get_coefs">
<span class="sig-name descname"><span class="pre">get_coefs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.get_coefs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.get_coefs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns dictionary of coefficients for linear models.</p>
<p>Only for models from sklearn.linear_model</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>coeffs</strong> – Dictionary of dictionaries for each variable with keys given by the
parents and the regression coefficients as values.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.get_general_fitted_model">
<span class="sig-name descname"><span class="pre">get_general_fitted_model</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conditions=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off='max_lag_or_tau_max'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">empty_predictors_function=&lt;function</span> <span class="pre">mean&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_data=False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.get_general_fitted_model"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.get_general_fitted_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit time series model.</p>
<p>For each variable in selected_variables, the sklearn model is fitted
with <img class="math" src="_images/math/1b5e577d6216dca3af7d87aa122a0b9b360d6cb3.png" alt="y"/> given by the target variable(s), and <img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> given by its
parents. The fitted model class is returned for later use.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>lists of tuples</em>) – List of variables for estimating model Y = f(X,Z)</p></li>
<li><p><strong>Y</strong> (<em>lists of tuples</em>) – List of variables for estimating model Y = f(X,Z)</p></li>
<li><p><strong>Z</strong> (<em>lists of tuples</em>) – List of variables for estimating model Y = f(X,Z)</p></li>
<li><p><strong>conditions</strong> (<em>list of tuples.</em>) – Conditions for estimating conditional causal effects.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum time lag. If None, the maximum lag in all_parents is used.</p></li>
<li><p><strong>cut_off</strong> (<em>{'max_lag_or_tau_max'</em><em>, </em><em>'2xtau_max'</em><em>, </em><em>'max_lag'}</em>) – How many samples to cutoff at the beginning. The default is
‘max_lag_or_tau_max’, which uses the maximum of tau_max and the
conditions. This is useful to compare multiple models on the same
sample. Other options are ‘2xtau_max’, which guarantees that MCI
tests are all conducted on the same samples. Last, ‘max_lag’ uses
as much samples as possible.</p></li>
<li><p><strong>empty_predictors_function</strong> (<em>function</em>) – Function to apply to y if no predictors are given.</p></li>
<li><p><strong>return_data</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to save the data array.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>fit_results</strong> – Returns the sklearn model after fitting. Also returns the data
transformation parameters.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary of sklearn model objects</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.get_general_prediction">
<span class="sig-name descname"><span class="pre">get_general_prediction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">intervention_data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conditions_data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transform_interventions_and_prediction=False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_further_pred_results=False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aggregation_func=&lt;function</span> <span class="pre">mean&gt;</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.get_general_prediction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.get_general_prediction" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict effect of intervention with fitted model.</p>
<p>Uses the model.predict() function of the sklearn model.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>intervention_data</strong> (<em>numpy array</em>) – Numpy array of shape (time, len(X)) that contains the do(X) values.</p></li>
<li><p><strong>conditions_data</strong> (<em>data object</em><em>, </em><em>optional</em>) – Numpy array of shape (time, len(S)) that contains the S=s values.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function (model and
conditional_model).</p></li>
<li><p><strong>transform_interventions_and_prediction</strong> (<em>bool</em><em> (</em><em>default: False</em><em>)</em>) – Whether to perform the inverse data_transform on prediction results.</p></li>
<li><p><strong>return_further_pred_results</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – In case the predictor class returns more than just the expected value,
the entire results can be returned.</p></li>
<li><p><strong>aggregation_func</strong> (<em>callable</em>) – Callable applied to output of ‘predict’. Default is ‘np.mean’.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Results from prediction.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.get_residuals_cov_mean">
<span class="sig-name descname"><span class="pre">get_residuals_cov_mean</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.get_residuals_cov_mean"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.get_residuals_cov_mean" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns covariance and means of residuals from fitted model.</p>
<p>Residuals are available as self.residuals.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>new_data</strong> (<em>data object</em><em>, </em><em>optional</em>) – New Tigramite dataframe object with optional new mask. Note that
the data will be cut off according to cut_off, see parameter
<cite>cut_off</cite> below.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Results from prediction.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.get_val_matrix">
<span class="sig-name descname"><span class="pre">get_val_matrix</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.get_val_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.get_val_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the coefficient array for different lags for linear model.</p>
<p>Requires fit_model() before. An entry val_matrix[i,j,tau] gives the
coefficient of the link from i to j at lag tau, including tau=0.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>val_matrix</strong> – Array of coefficients for each time lag, including lag-zero.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>array-like, shape (N, N, tau_max + 1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Models.predict_full_model">
<span class="sig-name descname"><span class="pre">predict_full_model</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'max_lag_or_tau_max'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Models.predict_full_model"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Models.predict_full_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict target variable with fitted model.</p>
<p>Uses the model.predict() function of the sklearn model.</p>
<p>A list of predicted time series for self.selected_variables is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>new_data</strong> (<em>data object</em><em>, </em><em>optional</em>) – New Tigramite dataframe object with optional new mask. Note that
the data will be cut off according to cut_off, see parameter
<cite>cut_off</cite> below.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function.</p></li>
<li><p><strong>cut_off</strong> (<em>{'2xtau_max'</em><em>, </em><em>'max_lag'</em><em>, </em><em>'max_lag_or_tau_max'}</em>) – How many samples to cutoff at the beginning. The default is
‘2xtau_max’, which guarantees that MCI tests are all conducted on
the same samples.  For modeling, ‘max_lag_or_tau_max’ can be used,
which uses the maximum of tau_max and the conditions, which is
useful to compare multiple models on the same sample. Last,
‘max_lag’ uses as much samples as possible.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Results from prediction.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<p>Derived classes:</p>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.models.</span></span><span class="sig-name descname"><span class="pre">LinearMediation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">StandardScaler()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation" title="Permalink to this definition">¶</a></dt>
<dd><p>Linear mediation analysis for time series models.</p>
<p>Fits linear model to parents and provides functions to return measures such
as causal effect, mediated causal effect, average causal effect, etc. as
described in <a class="footnote-reference brackets" href="#id23" id="id21" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a>. Also allows for contemporaneous links.</p>
<p>For general linear and nonlinear causal effect analysis including latent
variables and further functionality use the CausalEffects class.</p>
<p class="rubric">Notes</p>
<p>This class implements the following causal mediation measures introduced in
<a class="footnote-reference brackets" href="#id23" id="id22" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a>:</p>
<blockquote>
<div><ul class="simple">
<li><p>causal effect (CE)</p></li>
<li><p>mediated causal effect (MCE)</p></li>
<li><p>average causal effect (ACE)</p></li>
<li><p>average causal susceptibility (ACS)</p></li>
<li><p>average mediated causal effect (AMCE)</p></li>
</ul>
</div></blockquote>
<p>Consider a simple model of a causal chain as given in the Example with</p>
<div class="math">
<p><img src="_images/math/7b5b384bfd47bd6e8d707b3189aaab3a46c5ed04.png" alt="X_t &amp;= \eta^X_t \\
Y_t &amp;= 0.5 X_{t-1} +  \eta^Y_t \\
Z_t &amp;= 0.5 Y_{t-1} +  \eta^Z_t"/></p>
</div><p>Here the link coefficient of <img class="math" src="_images/math/64932505aadaa1eac6316ff09c2c3b101b068168.png" alt="X_{t-2} \to Z_t"/> is zero while the
causal effect is 0.25. MCE through <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> is 0.25 implying that <em>all</em>
of the the CE is explained by <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/>. ACE from <img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> is 0.37 since it
has CE 0.5 on <img class="math" src="_images/math/7daf0d4815e763eb90f0d5f1dc406f668c1e21db.png" alt="Y"/> and 0.25 on <img class="math" src="_images/math/95f028ab2b20b895fa12d986e0d9f40f7b6e52d3.png" alt="Z"/>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">links_coeffs</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="p">[],</span> <span class="mi">1</span><span class="p">:</span> <span class="p">[((</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="mf">0.5</span><span class="p">)],</span> <span class="mi">2</span><span class="p">:</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="mf">0.5</span><span class="p">)]}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span><span class="p">,</span> <span class="n">true_parents</span> <span class="o">=</span> <span class="n">toys</span><span class="o">.</span><span class="n">var_process</span><span class="p">(</span><span class="n">links_coeffs</span><span class="p">,</span> <span class="n">T</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">pp</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">med</span> <span class="o">=</span> <span class="n">LinearMediation</span><span class="p">(</span><span class="n">dataframe</span><span class="o">=</span><span class="n">dataframe</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">med</span><span class="o">.</span><span class="n">fit_model</span><span class="p">(</span><span class="n">all_parents</span><span class="o">=</span><span class="n">true_parents</span><span class="p">,</span> <span class="n">tau_max</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Link coefficient (0, -2) --&gt; 2: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_coeff</span><span class="p">(</span>
<span class="go">i=0, tau=-2, j=2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Causal effect (0, -2) --&gt; 2: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_ce</span><span class="p">(</span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">tau</span><span class="o">=-</span><span class="mi">2</span><span class="p">,</span> <span class="n">j</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Mediated Causal effect (0, -2) --&gt; 2 through 1: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_mce</span><span class="p">(</span>
<span class="go">i=0, tau=-2, j=2, k=1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Average Causal Effect: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_all_ace</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Average Causal Susceptibility: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_all_acs</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="s2">&quot;Average Mediated Causal Effect: &quot;</span><span class="p">,</span> <span class="n">med</span><span class="o">.</span><span class="n">get_all_amce</span><span class="p">()</span>
<span class="go">Link coefficient (0, -2) --&gt; 2:  0.0</span>
<span class="go">Causal effect (0, -2) --&gt; 2:  0.250648072987</span>
<span class="go">Mediated Causal effect (0, -2) --&gt; 2 through 1:  0.250648072987</span>
<span class="go">Average Causal Effect:  [ 0.36897445  0.25718002  0.        ]</span>
<span class="go">Average Causal Susceptibility:  [ 0.          0.24365041  0.38250406]</span>
<span class="go">Average Mediated Causal Effect:  [ 0.          0.12532404  0.        ]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<aside class="footnote brackets" id="id23" role="note">
<span class="label"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id21">1</a>,<a role="doc-backlink" href="#id22">2</a>,<a role="doc-backlink" href="#id24">3</a>)</span>
<p>J. Runge et al. (2015): Identifying causal gateways and mediators in
complex spatio-temporal systems.
Nature Communications, 6, 8502. <a class="reference external" href="http://doi.org/10.1038/ncomms9502">http://doi.org/10.1038/ncomms9502</a></p>
</aside>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>model_params</strong> (<em>dictionary</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional parameters passed on to sklearn model</p></li>
<li><p><strong>data_transform</strong> (<em>sklearn preprocessing object</em><em>, </em><em>optional</em><em> (</em><em>default: StandardScaler</em><em>)</em>) – Used to transform data prior to fitting. For example,
sklearn.preprocessing.StandardScaler for simple standardization. The
fitted parameters are stored.</p></li>
<li><p><strong>mask_type</strong> (<em>{None</em><em>, </em><em>'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.fit_model">
<span class="sig-name descname"><span class="pre">fit_model</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all_parents</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.fit_model"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.fit_model" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit linear time series model.</p>
<p>Fits a sklearn.linear_model.LinearRegression model to the parents of
each variable and computes the coefficient matrices <img class="math" src="_images/math/d8ee85ac4d75924cdf4b18f5fb3b46550932fc26.png" alt="\Phi"/> and
<img class="math" src="_images/math/20582dab63cb7f6604f5bf70224030ad3411ae16.png" alt="\Psi"/> as described in <a class="footnote-reference brackets" href="#id23" id="id24" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a>. Does accept contemporaneous links.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>all_parents</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, 0), …], 1:[], …} containing
the parents estimated with PCMCI.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum time lag. If None, the maximum lag in all_parents is used.</p></li>
<li><p><strong>return_data</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to save the data array. Needed to get residuals.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.fit_model_bootstrap">
<span class="sig-name descname"><span class="pre">fit_model_bootstrap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">boot_blocklength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boot_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.fit_model_bootstrap"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.fit_model_bootstrap" title="Permalink to this definition">¶</a></dt>
<dd><p>Fits boostrap-versions of Phi, Psi, etc.</p>
<p>Random draws are generated</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>boot_blocklength</strong> (<em>int</em><em>, or </em><em>in {'cube_root'</em><em>, </em><em>'from_autocorrelation'}</em>) – Block length for block-bootstrap. If ‘cube_root’ it is the cube
root of the time series length.</p></li>
<li><p><strong>seed</strong> (<em>int</em><em>, </em><em>optional</em><em>(</em><em>default = None</em><em>)</em>) – Seed for RandomState (default_rng)</p></li>
<li><p><strong>boot_samples</strong> (<em>int</em>) – Number of bootstrap samples.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_ace">
<span class="sig-name descname"><span class="pre">get_ace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_i</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_ace"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_ace" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average causal effect.</p>
<p>This is the average causal effect (ACE) emanating from variable i to any
other variable. With lag_mode=’absmax’ this is based on the lag of
maximum CE for each pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_i</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects on the variable itself at later
lags.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>ace</strong> – Average Causal Effect.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_acs">
<span class="sig-name descname"><span class="pre">get_acs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_j</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_acs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_acs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average causal susceptibility.</p>
<p>This is the Average Causal Susceptibility (ACS) affecting a variable j
from any other variable. With lag_mode=’absmax’ this is based on the lag
of maximum CE for each pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>j</strong> (<em>int</em>) – Index of variable.</p></li>
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_j</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects on the variable itself at previous
lags.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>acs</strong> – Average Causal Susceptibility.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_all_ace">
<span class="sig-name descname"><span class="pre">get_all_ace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_i</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_all_ace"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_all_ace" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average causal effect for all variables.</p>
<p>This is the average causal effect (ACE) emanating from variable i to any
other variable. With lag_mode=’absmax’ this is based on the lag of
maximum CE for each pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_i</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects on the variable itself at later
lags.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>ace</strong> – Average Causal Effect for each variable.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N,)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_all_acs">
<span class="sig-name descname"><span class="pre">get_all_acs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_j</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_all_acs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_all_acs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average causal susceptibility.</p>
<p>This is the Average Causal Susceptibility (ACS) for each variable from
any other variable. With lag_mode=’absmax’ this is based on the lag of
maximum CE for each pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_j</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects on the variable itself at previous
lags.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>acs</strong> – Average Causal Susceptibility.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N,)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_all_amce">
<span class="sig-name descname"><span class="pre">get_all_amce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_k</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_self_effects</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_all_amce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_all_amce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average mediated causal effect.</p>
<p>This is the Average Mediated Causal Effect (AMCE) through all variables
With lag_mode=’absmax’ this is based on the lag of maximum CE for each
pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_k</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects through the variable itself at
previous lags.</p></li>
<li><p><strong>exclude_self_effects</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal self effects of variables on themselves.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>amce</strong> – Average Mediated Causal Effect.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N,)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_amce">
<span class="sig-name descname"><span class="pre">get_amce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">k</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'absmax'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_k</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_self_effects</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_amce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_amce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the average mediated causal effect.</p>
<p>This is the Average Mediated Causal Effect (AMCE) through a variable k
With lag_mode=’absmax’ this is based on the lag of maximum CE for each
pair.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>k</strong> (<em>int</em>) – Index of variable.</p></li>
<li><p><strong>lag_mode</strong> (<em>{'absmax'</em><em>, </em><em>'all_lags'}</em>) – Lag mode. Either average across all lags between each pair or only
at the lag of maximum absolute causal effect.</p></li>
<li><p><strong>exclude_k</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal effects through the variable itself at
previous lags.</p></li>
<li><p><strong>exclude_self_effects</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to exclude causal self effects of variables on themselves.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>amce</strong> – Average Mediated Causal Effect.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_bootstrap_of">
<span class="sig-name descname"><span class="pre">get_bootstrap_of</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function_args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_lev</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.9</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_bootstrap_of"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_bootstrap_of" title="Permalink to this definition">¶</a></dt>
<dd><p>Applies bootstrap-versions of Phi, Psi, etc. to any function in
this class.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>function</strong> (<em>string</em>) – Valid function from LinearMediation class</p></li>
<li><p><strong>function_args</strong> (<em>dict</em>) – Optional function arguments.</p></li>
<li><p><strong>conf_lev</strong> (<em>float</em>) – Confidence interval.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Upper/Lower confidence interval of function.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_ce">
<span class="sig-name descname"><span class="pre">get_ce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_ce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_ce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the causal effect.</p>
<p>This is the causal effect for  (i, -tau) – –&gt; j.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>tau</strong> (<em>int</em>) – Lag of cause variable (incl lag zero).</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>ce</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_ce_max">
<span class="sig-name descname"><span class="pre">get_ce_max</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_ce_max"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_ce_max" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the causal effect.</p>
<p>This is the maximum absolute causal effect for  i –&gt; j across all
lags (incl lag zero).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>ce</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_coeff">
<span class="sig-name descname"><span class="pre">get_coeff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_coeff"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_coeff" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns link coefficient.</p>
<p>This is the direct causal effect for a particular link (i, -tau) –&gt; j.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>tau</strong> (<em>int</em>) – Lag of cause variable (incl lag zero).</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>coeff</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_conditional_mce">
<span class="sig-name descname"><span class="pre">get_conditional_mce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">notk</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_conditional_mce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_conditional_mce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the conditional mediated causal effect.</p>
<p>This is the causal effect for  i –&gt; j for all paths going through k, but not through notk.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>tau</strong> (<em>int</em>) – Lag of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
<li><p><strong>k</strong> (<em>int</em><em> or </em><em>list of ints</em>) – Indices of mediator variables.</p></li>
<li><p><strong>notk</strong> (<em>int</em><em> or </em><em>list of ints</em>) – Indices of mediator variables to exclude.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>mce</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_joint_ce">
<span class="sig-name descname"><span class="pre">get_joint_ce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_joint_ce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_joint_ce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the joint causal effect.</p>
<p>This is the causal effect from all lags [t, …, t-tau_max]
of i on j at time t. Note that the joint effect does not
count links passing through parents of i itself.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>joint_ce</strong> – Causal effect from each lag [t, …, t-tau_max] of i on j.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (tau_max + 1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_joint_ce_matrix">
<span class="sig-name descname"><span class="pre">get_joint_ce_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_joint_ce_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_joint_ce_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the joint causal effect matrix of i on j.</p>
<p>This is the causal effect from all lags [t, …, t-tau_max]
of i on j at times [t, …, t-tau_max]. Note that the joint effect does not
count links passing through parents of i itself.</p>
<p>An entry (taui, tauj) stands for the effect of i at t-taui on j at t-tauj.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>joint_ce_matrix</strong> – Causal effect matrix from each lag of i on each lag of j.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>2d array of shape (tau_max + 1, tau_max + 1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_joint_mce">
<span class="sig-name descname"><span class="pre">get_joint_mce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_joint_mce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_joint_mce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the joint causal effect mediated through k.</p>
<p>This is the mediated causal effect from all lags [t, …, t-tau_max]
of i on j at time t for paths through k. Note that the joint effect
does not count links passing through parents of i itself.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
<li><p><strong>k</strong> (<em>int</em><em> or </em><em>list of ints</em>) – Indices of mediator variables.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>joint_mce</strong> – Mediated causal effect from each lag [t, …, t-tau_max] of i on j through k.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (tau_max + 1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_mce">
<span class="sig-name descname"><span class="pre">get_mce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_mce"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_mce" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the mediated causal effect.</p>
<p>This is the causal effect for  i –&gt; j minus the causal effect not going
through k.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>tau</strong> (<em>int</em>) – Lag of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
<li><p><strong>k</strong> (<em>int</em><em> or </em><em>list of ints</em>) – Indices of mediator variables.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>mce</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_mediation_graph_data">
<span class="sig-name descname"><span class="pre">get_mediation_graph_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_neighbors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_mediation_graph_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_mediation_graph_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns link and node weights for mediation analysis.</p>
<p>Returns array with non-zero entries for links that are on causal
paths between <img class="math" src="_images/math/5aa339d4daf45a810dda332e3c80a0698e526e04.png" alt="i"/> and <img class="math" src="_images/math/e3fc28292267f066fee7718c64f4bbfece521f24.png" alt="j"/> at lag <img class="math" src="_images/math/914b2d4b6659b86d3153d5510839dfb254dfc8a3.png" alt="\tau"/>.
<code class="docutils literal notranslate"><span class="pre">path_val_matrix</span></code> contains the corresponding path coefficients and
<code class="docutils literal notranslate"><span class="pre">path_node_array</span></code> the MCE values. <code class="docutils literal notranslate"><span class="pre">tsg_path_val_matrix</span></code> contains the
corresponding values in the time series graph format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>i</strong> (<em>int</em>) – Index of cause variable.</p></li>
<li><p><strong>tau</strong> (<em>int</em>) – Lag of cause variable.</p></li>
<li><p><strong>j</strong> (<em>int</em>) – Index of effect variable.</p></li>
<li><p><strong>include_neighbors</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to include causal paths emanating from neighbors of i</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>graph_data</strong> – Dictionary of matrices for coloring mediation graph plots.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_tsg">
<span class="sig-name descname"><span class="pre">get_tsg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include_neighbors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_tsg"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_tsg" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns time series graph matrix.</p>
<p>Constructs a matrix of shape (N*tau_max, N*tau_max) from link_matrix.
This matrix can be used for plotting the time series graph and analyzing
causal pathways.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>link_matrix</strong> (<em>bool array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Matrix of significant links. Must be of same shape as val_matrix.
Either sig_thres or link_matrix has to be provided.</p></li>
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing test statistic values.</p></li>
<li><p><strong>include_neighbors</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to include causal paths emanating from neighbors of i</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>tsg</strong> – Time series graph matrix.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N*tau_max, N*tau_max)</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.get_val_matrix">
<span class="sig-name descname"><span class="pre">get_val_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">symmetrize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.get_val_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.get_val_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the matrix of linear coefficients.</p>
<p>Requires fit_model() before. An entry val_matrix[i,j,tau] gives the
coefficient of the link from i to j at lag tau. Lag=0 is always set
to zero for LinearMediation, use Models class for contemporaneous
models.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>symmetrize</strong> (<em>bool</em>) – If True, the lag-zero entries will be symmetrized such that
no zeros appear. Useful since other parts of tigramite
through an error for non-symmetric val_matrix, eg plotting.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>val_matrix</strong> – Matrix of linear coefficients, shape (N, N, tau_max + 1).</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.net_to_tsg">
<span class="sig-name descname"><span class="pre">net_to_tsg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">row</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lag</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.net_to_tsg"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.net_to_tsg" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to translate from network to time series graph.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.LinearMediation.tsg_to_net">
<span class="sig-name descname"><span class="pre">tsg_to_net</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lag</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#LinearMediation.tsg_to_net"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.LinearMediation.tsg_to_net" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to translate from time series graph to network.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.models.Prediction">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.models.</span></span><span class="sig-name descname"><span class="pre">Prediction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">train_indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">test_indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prediction_model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cond_ind_test</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction" title="Permalink to this definition">¶</a></dt>
<dd><p>Prediction class for time series models.</p>
<p>Allows to fit and predict from any sklearn model. The optimal predictors can
be estimated using PCMCI. Also takes care of missing values, masking and
preprocessing.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>train_indices</strong> (<em>array-like</em>) – Either boolean array or time indices marking the training data.</p></li>
<li><p><strong>test_indices</strong> (<em>array-like</em>) – Either boolean array or time indices marking the test data.</p></li>
<li><p><strong>prediction_model</strong> (<em>sklearn model object</em>) – For example, sklearn.linear_model.LinearRegression() for a linear
regression model.</p></li>
<li><p><strong>cond_ind_test</strong> (<em>Conditional independence test object</em><em>, </em><em>optional</em>) – Only needed if predictors are estimated with causal algorithm.
The class will be initialized with masking set to the training data.</p></li>
<li><p><strong>data_transform</strong> (<em>sklearn preprocessing object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Used to transform data prior to fitting. For example,
sklearn.preprocessing.StandardScaler for simple standardization. The
fitted parameters are stored.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Prediction.fit">
<span class="sig-name descname"><span class="pre">fit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target_predictors</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_targets</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction.fit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit time series model.</p>
<p>Wrapper around <code class="docutils literal notranslate"><span class="pre">Models.fit_full_model()</span></code>. To each variable in
<code class="docutils literal notranslate"><span class="pre">selected_targets</span></code>, the sklearn model is fitted with <img class="math" src="_images/math/1b5e577d6216dca3af7d87aa122a0b9b360d6cb3.png" alt="y"/> given
by the target variable, and <img class="math" src="_images/math/ed38fa24f1c94891bd312012aab3f6673be3eb83.png" alt="X"/> given by its predictors. The
fitted model class is returned for later use.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target_predictors</strong> (<em>dictionary</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …} containing
the predictors estimated with PCMCI.</p></li>
<li><p><strong>selected_targets</strong> (<em>list of integers</em><em>, </em><em>optional</em><em> (</em><em>default: range</em><em>(</em><em>N</em><em>)</em><em>)</em>) – Specify to fit model only for selected targets. If None is
passed, models are estimated for all variables.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Maximum time lag. If None, the maximum lag in target_predictors is
used.</p></li>
<li><p><strong>return_data</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to save the data array.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>self</strong></p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>instance of self</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Prediction.get_predictors">
<span class="sig-name descname"><span class="pre">get_predictors</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected_targets</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps_ahead</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pc_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_conds_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_combinations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction.get_predictors"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction.get_predictors" title="Permalink to this definition">¶</a></dt>
<dd><p>Estimate predictors using PC1 algorithm.</p>
<p>Wrapper around PCMCI.run_pc_stable that estimates causal predictors.
The lead time can be specified by <code class="docutils literal notranslate"><span class="pre">steps_ahead</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>selected_targets</strong> (<em>list of ints</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variables to estimate predictors of. If None, predictors of
all variables are estimated.</p></li>
<li><p><strong>selected_links</strong> (<em>dict</em><em> or </em><em>None</em>) – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …}
specifying whether only selected links should be tested. If None is
passed, all links are tested</p></li>
<li><p><strong>steps_ahead</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Minimum time lag to test. Useful for multi-step ahead predictions.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum time lag. Must be larger or equal to tau_min.</p></li>
<li><p><strong>pc_alpha</strong> (<em>float</em><em> or </em><em>list of floats</em><em>, </em><em>default: 0.2</em>) – Significance level in algorithm. If a list or None is passed, the
pc_alpha level is optimized for every variable across the given
pc_alpha values using the score computed in
cond_ind_test.get_model_selection_criterion()</p></li>
<li><p><strong>max_conds_dim</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum number of conditions to test. If None is passed, this number
is unrestricted.</p></li>
<li><p><strong>max_combinations</strong> (<em>int</em><em>, </em><em>default: 1</em>) – Maximum number of combinations of conditions of current cardinality
to test. Defaults to 1 for PC_1 algorithm. For original PC algorithm
a larger number, such as 10, can be used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>predictors</strong> – Dictionary of form {0:[(0, -1), (3, -2), …], 1:[], …}
containing estimated predictors.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Prediction.get_test_array">
<span class="sig-name descname"><span class="pre">get_test_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction.get_test_array"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction.get_test_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns test array for variable j.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Prediction.get_train_array">
<span class="sig-name descname"><span class="pre">get_train_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">j</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction.get_train_array"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction.get_train_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns training array for variable j.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.models.Prediction.predict">
<span class="sig-name descname"><span class="pre">predict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">new_data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pred_params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'max_lag_or_tau_max'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/models.html#Prediction.predict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.models.Prediction.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict target variable with fitted model.</p>
<p>Uses the model.predict() function of the sklearn model.</p>
<p>If target is an int, the predicted time series is returned. If target
is a list of integers, then a list of predicted time series is returned.
If the list of integers equals range(N), then an array of shape (T, N)
of the predicted series is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<em>int</em><em> or </em><em>list of integers</em>) – Index or indices of target variable(s).</p></li>
<li><p><strong>new_data</strong> (<em>data object</em><em>, </em><em>optional</em>) – New Tigramite dataframe object with optional new mask. Note that
the data will be cut off according to cut_off, see parameter
<cite>cut_off</cite> below.</p></li>
<li><p><strong>pred_params</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional parameters passed on to sklearn prediction function.</p></li>
<li><p><strong>cut_off</strong> (<em>{'2xtau_max'</em><em>, </em><em>'max_lag'</em><em>, </em><em>'max_lag_or_tau_max'}</em>) – How many samples to cutoff at the beginning. The default is
‘2xtau_max’, which guarantees that MCI tests are all conducted on
the same samples.  For modeling, ‘max_lag_or_tau_max’ can be used,
which uses the maximum of tau_max and the conditions, which is
useful to compare multiple models on the same sample. Last,
‘max_lag’ uses as much samples as possible.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>Results from prediction.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>
<section id="module-tigramite.data_processing">
<span id="tigramite-data-processing-data-processing-functions"></span><h1><a class="reference internal" href="#module-tigramite.data_processing" title="tigramite.data_processing"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.data_processing</span></code></a>: Data processing functions<a class="headerlink" href="#module-tigramite.data_processing" title="Permalink to this heading">¶</a></h1>
<p>Tigramite data processing functions.</p>
<dl class="py class">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">DataFrame</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">missing_flag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vector_vars</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">datatime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">analysis_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'single'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reference_points</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time_offsets</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remove_missing_upto_maxlag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#DataFrame"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.DataFrame" title="Permalink to this definition">¶</a></dt>
<dd><p>Data object containing single or multiple time series arrays and optional
mask, as well as variable definitions.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array-like</em>) – <dl class="simple">
<dt>if analysis_mode == ‘single’:</dt><dd><p>Numpy array of shape (observations T, variables N)
OR
Dictionary with a single entry whose value is a numpy array of
shape (observations T, variables N)</p>
</dd>
<dt>if analysis_mode == ‘multiple’:</dt><dd><p>Numpy array of shape (multiple datasets M, observations T,
variables N)
OR
Dictionary whose values are numpy arrays of shape
(observations T_i, variables N), where the number of observations
T_i may vary across the multiple datasets but the number of variables
N is fixed.</p>
</dd>
</dl>
</p></li>
<li><p><strong>mask</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional mask array, must be of same format and shape as data.</p></li>
<li><p><strong>data_type</strong> (<em>array-like</em>) – Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p></li>
<li><p><strong>missing_flag</strong> (<em>number</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Flag for missing values in dataframe. Dismisses all time slices of
samples where missing values occur in any variable. For
remove_missing_upto_maxlag=True also flags samples for all lags up to
2*tau_max (more precisely, this depends on the cut_off argument in
self.construct_array(), see further below). This avoids biases, see
section on masking in Supplement of Runge et al. SciAdv (2019).</p></li>
<li><p><strong>vector_vars</strong> (<em>dict</em>) – Dictionary of vector variables of the form,
Eg. {0: [(0, 0), (1, 0)], 1: [(2, 0)], 2: [(3, 0)], 3: [(4, 0)]}
The keys are the new vectorized variables and respective tuple values
are the individual components of the vector variables. In the method of
construct_array(), the individual components are parsed from vector_vars
and added (accounting for lags) to the list that creates X, Y and Z for
conditional independence test.</p></li>
<li><p><strong>var_names</strong> (<em>list of strings</em><em>, </em><em>optional</em><em> (</em><em>default: range</em><em>(</em><em>N</em><em>)</em><em>)</em>) – Names of variables, must match the number of variables. If None is
passed, variables are enumerated as [0, 1, …]</p></li>
<li><p><strong>datatime</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Timelabel array. If None, range(T) is used.</p></li>
<li><p><strong>remove_missing_upto_maxlag</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to remove not only missing samples, but also all neighboring
samples up to max_lag (as given by cut_off in construct_array).</p></li>
<li><p><strong>analysis_mode</strong> (<em>string</em><em>, </em><em>optional</em><em> (</em><em>default: 'single'</em><em>)</em>) – Must be ‘single’ or ‘multiple’.
Determines whether data contains a single (potentially multivariate)
time series (–&gt; ‘single’) or multiple time series (–&gt; ‘multiple’).</p></li>
<li><p><strong>reference_points</strong> (<em>None</em><em>, </em><em>int</em><em>, or </em><em>list</em><em> (or </em><em>1D array</em><em>) </em><em>of integers</em><em>,</em>) – optional (default:None)
Determines the time steps — relative to the shared time axis as
defined by the optional time_offset argument (see below) — that are
used to create samples for conditional independence testing.
Set to [0, 1, …, T_max-1] if None is passed, where T_max is
self.largest_time_step, see below.
All values smaller than 0 and bigger than T_max-1 will be ignored.
At least one value must be in [0, 1, …, T_max-1].</p></li>
<li><p><strong>time_offsets</strong> (<em>None</em><em> or </em><em>dict</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – <dl class="simple">
<dt>if analysis_mode == ‘single’:</dt><dd><p>Must be None.
Shared time axis defined by the time indices of the single time series</p>
</dd>
<dt>if analysis_mode == ‘multiple’ and data is numpy array:</dt><dd><p>Must be None.
All datasets are assumed to be already aligned in time with
respect to a shared time axis, which is the time axis of data</p>
</dd>
<dt>if analysis_mode == ‘multiple’ and data is dictionary:</dt><dd><p>Must be dictionary of the form {key(m): time_offset(m), …} whose
set of keys agrees with the set of keys of data and whose values are
non-negative integers, at least one of which is 0. The value
time_offset(m) defines the time offset of dataset m with
respect to a shared time axis.</p>
</dd>
</dl>
</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self._initialized_from">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">_initialized_from</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self._initialized_from" title="Permalink to this definition">¶</a></dt>
<dd><p>Specifies the data format in which data was given at instantiation.
Possible values: ‘2d numpy array’, ‘3d numpy array’, ‘dict’.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.values">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">values</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.values" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary holding the observations given by data internally mapped to a
dictionary representation as follows:
If analysis_mode == ‘single’: for self._initialized_from == ‘2d numpy array’ this
is {0: data} and for self._initialized_from == ‘dict’ this is data.
If analysis_mode == ‘multiple’: If self._initialized_from == ‘3d numpy array’, this is
{m: data[m, :, :] for m in range(data.shape[0])} and for self._initialized_from == ‘dict’ this
is data.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.datasets">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">datasets</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.datasets" title="Permalink to this definition">¶</a></dt>
<dd><p>List of the keys identifiying the multiple datasets, i.e.,
list(self.values.keys())</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.mask">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">mask</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.mask" title="Permalink to this definition">¶</a></dt>
<dd><p>Mask internally mapped to a dictionary representation in the same way as
data is mapped to self.values</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.data_type">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">data_type</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.data_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array-like</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.missing_flag">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">missing_flag</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.missing_flag" title="Permalink to this definition">¶</a></dt>
<dd><p>Is missing_flag</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.var_names">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">var_names</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.var_names" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>If var_names is not None:</dt><dd><p>Is var_names</p>
</dd>
<dt>If var_names is None:</dt><dd><p>Is {i: i for i in range(self.N)}</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.datatime">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">datatime</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.datatime" title="Permalink to this definition">¶</a></dt>
<dd><p>Time axis for each of the multiple datasets.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.analysis_mode">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">analysis_mode</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.analysis_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>Is analysis_mode</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>string</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.reference_points">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">reference_points</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.reference_points" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>If reference_points is not None:</dt><dd><p>1D numpy array holding all specified reference_points, less those
smaller than 0 and larger than self.largest_time_step-1</p>
</dd>
<dt>If reference_points is None:</dt><dd><p>Is np.array(self.largest_time_step)</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array-like</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.time_offsets">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">time_offsets</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.time_offsets" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>If time_offsets is not None:</dt><dd><p>Is time_offsets</p>
</dd>
<dt>If time_offsets is None:</dt><dd><p>Is {key: 0 for key in self.values.keys()}</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.M">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">M</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.M" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of datasets</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.N">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">N</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.N" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of variables (constant across datasets)</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.T">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">T</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.T" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary {key(m): T(m), …}, where T(m) is the time length of
datasets m and key(m) its identifier as in self.values</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.largest_time_step">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">largest_time_step</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.largest_time_step" title="Permalink to this definition">¶</a></dt>
<dd><p>max_{0 &lt;= m &lt;= M} [ T(m) + time_offset(m)], i.e., the largest (latest)
time step relative to the shared time axis for which at least one
observation exists in the dataset.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.self.bootstrap">
<span class="sig-prename descclassname"><span class="pre">self.</span></span><span class="sig-name descname"><span class="pre">bootstrap</span></span><a class="headerlink" href="#tigramite.data_processing.DataFrame.self.bootstrap" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether to use bootstrap. Must be a dictionary with keys random_state,
boot_samples, and boot_blocklength.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.construct_array">
<span class="sig-name descname"><span class="pre">construct_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extraZ</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_cleaned_xyz</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">do_checks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">remove_overlaps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cut_off</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'2xtau_max'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#DataFrame.construct_array"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.DataFrame.construct_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs array from variables X, Y, Z from data.
Data is of shape (T, N) if analysis_mode == ‘single’, where T is the
time series length and N the number of variables, and of (n_ens, T, N)
if analysis_mode == ‘multiple’.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), X, Y, Z can be multivariate of
the form [(var1, -lag), (var2, -lag), …]. At least one varlag in Y
has to be at lag zero. extraZ is only used in CausalEffects class.</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), X, Y, Z can be multivariate of
the form [(var1, -lag), (var2, -lag), …]. At least one varlag in Y
has to be at lag zero. extraZ is only used in CausalEffects class.</p></li>
<li><p><strong>Z</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), X, Y, Z can be multivariate of
the form [(var1, -lag), (var2, -lag), …]. At least one varlag in Y
has to be at lag zero. extraZ is only used in CausalEffects class.</p></li>
<li><p><strong>extraZ</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), X, Y, Z can be multivariate of
the form [(var1, -lag), (var2, -lag), …]. At least one varlag in Y
has to be at lag zero. extraZ is only used in CausalEffects class.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em>) – Maximum time lag. This may be used to make sure that estimates for
different lags in X and Z all have the same sample size.</p></li>
<li><p><strong>mask</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional mask array, must be of same shape as data.  If it is set,
then it overrides the self.mask assigned to the dataframe. If it is
None, then the self.mask is used, if it exists.</p></li>
<li><p><strong>mask_type</strong> (<em>{None</em><em>, </em><em>'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>data_type</strong> (<em>array-like</em>) – Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.
If it is set, then it overrides the self.data_type assigned to the dataframe.</p></li>
<li><p><strong>return_cleaned_xyz</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to return cleaned X,Y,Z, where possible duplicates are
removed.</p></li>
<li><p><strong>do_checks</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to perform sanity checks on input X,Y,Z</p></li>
<li><p><strong>remove_overlaps</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to remove variables from Z/extraZ if they overlap with X or Y.</p></li>
<li><p><strong>cut_off</strong> (<em>{'2xtau_max'</em><em>, </em><em>'tau_max'</em><em>, </em><em>'max_lag'</em><em>, </em><em>'max_lag_or_tau_max'</em><em>, </em><em>2xtau_max_future}</em>) – <dl class="simple">
<dt>If cut_off == ‘2xtau_max’:</dt><dd><ul>
<li><p>2*tau_max samples are cut off at the beginning of the time
series (‘beginning’ here refers to the temporally first
time steps). This guarantees that (as long as no mask is
used) all MCI tests are conducted on the same samples,
independent of X, Y, and Z.</p></li>
<li><p>If at time step t_missing a data value is missing, then the
time steps t_missing, …, t_missing + 2*tau_max are cut
out. The latter part only holds if
remove_missing_upto_maxlag=True.</p></li>
</ul>
</dd>
<dt>If cut_off ==  ‘max_lag’:</dt><dd><ul>
<li><p>max_lag(X, Y, Z) samples are cut off at the beginning of the
time series, where max_lag(X, Y, Z) is the maximum lag of
all nodes in X, Y, and Z. These are all samples that can in
principle be used.</p></li>
<li><p>If at time step t_missing a data value is missing, then the
time steps t_missing, …, t_missing + max_lag(X, Y, Z) are
cut out. The latter part only holds if
remove_missing_upto_maxlag=True.</p></li>
</ul>
</dd>
<dt>If cut_off == ‘max_lag_or_tau_max’:</dt><dd><ul>
<li><p>max(max_lag(X, Y, Z), tau_max) are cut off at the beginning.
This may be useful for modeling by comparing multiple
models on the same samples.</p></li>
<li><p>If at time step t_missing a data value is missing, then the
time steps t_missing, …, t_missing + max(max_lag(X, Y,
Z), tau_max) are cut out. The latter part only holds if
remove_missing_upto_maxlag=True.</p></li>
</ul>
</dd>
<dt>If cut_off == ‘tau_max’:</dt><dd><ul>
<li><p>tau_max samples are cut off at the beginning. This may be
useful for modeling by comparing multiple models on the
same samples.</p></li>
<li><p>If at time step t_missing a data value is missing, then the
time steps t_missing, …, t_missing + max(max_lag(X, Y,
Z), tau_max) are cut out. The latter part only holds if
remove_missing_upto_maxlag=True.</p></li>
</ul>
</dd>
<dt>If cut_off == ‘2xtau_max_future’:</dt><dd><p>First, the relevant time steps are determined as for cut_off ==
‘max_lag’. Then, the temporally latest time steps are removed
such that the same number of time steps remains as there would
be for cut_off == ‘2xtau_max’. This may be useful when one is
mostly interested in the temporally first time steps and would
like all MCI tests to be performed on the same <em>number</em> of
samples. Note, however, that while the <em>number</em> of samples is
the same for all MCI tests, the samples themselves may be
different.</p>
</dd>
</dl>
</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>array, xyz [,XYZ], data_type</strong> – xyz identifier array of shape (dim,) identifying which row in array
corresponds to X, Y, and Z, and the type mask that indicates which samples
are continuous or discrete. For example: X = [(0, -1)],
Y = [(1, 0)], Z = [(1, -1), (0, -2)] yields an array of shape
(4, n_samples) and xyz is xyz = numpy.array([0,1,2,2]). If
return_cleaned_xyz is True, also outputs the cleaned XYZ lists.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Tuple of data array of shape (dim, n_samples),</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.data_processing.DataFrame.print_array_info">
<span class="sig-name descname"><span class="pre">print_array_info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">missing_flag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extraZ</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#DataFrame.print_array_info"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.DataFrame.print_array_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Print info about the constructed array</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>Data array of shape</em><em> (</em><em>dim</em><em>, </em><em>T</em><em>)</em>) – Data array.</p></li>
<li><p><strong>X</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), Y is of the form [(varY, 0)],
where var specifies the variable index. X typically is of the form
[(varX, -tau)] with tau denoting the time lag and Z can be
multivariate [(var1, -lag), (var2, -lag), …] .</p></li>
<li><p><strong>Y</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), Y is of the form [(varY, 0)],
where var specifies the variable index. X typically is of the form
[(varX, -tau)] with tau denoting the time lag and Z can be
multivariate [(var1, -lag), (var2, -lag), …] .</p></li>
<li><p><strong>Z</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), Y is of the form [(varY, 0)],
where var specifies the variable index. X typically is of the form
[(varX, -tau)] with tau denoting the time lag and Z can be
multivariate [(var1, -lag), (var2, -lag), …] .</p></li>
<li><p><strong>extraZ</strong> (<em>list of tuples</em>) – For a dependence measure I(X;Y|Z), Y is of the form [(varY, 0)],
where var specifies the variable index. X typically is of the form
[(varX, -tau)] with tau denoting the time lag and Z can be
multivariate [(var1, -lag), (var2, -lag), …] .</p></li>
<li><p><strong>missing_flag</strong> (<em>number</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Flag for missing values. Dismisses all time slices of samples where
missing values occur in any variable and also flags samples for all
lags up to 2*tau_max. This avoids biases, see section on masking in
Supplement of <a class="footnote-reference brackets" href="#id5" id="id25" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p></li>
<li><p><strong>mask_type</strong> (<em>{'y'</em><em>,</em><em>'x'</em><em>,</em><em>'z'</em><em>,</em><em>'xy'</em><em>,</em><em>'xz'</em><em>,</em><em>'yz'</em><em>,</em><em>'xyz'}</em>) – Masking mode: Indicators for which variables in the dependence
measure I(X; Y | Z) the samples should be masked. If None, the mask
is not used. Explained in tutorial on masking and missing values.</p></li>
<li><p><strong>data_type</strong> (<em>array-like</em>) – Binary data array of same shape as array which describes whether
individual samples in a variable (or all samples) are continuous
or discrete: 0s for continuous variables and 1s for discrete variables.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.get_acf">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">get_acf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">series</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#get_acf"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.get_acf" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns autocorrelation function.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>series</strong> (<em>1D-array</em>) – data series to compute autocorrelation from</p></li>
<li><p><strong>max_lag</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – maximum lag for autocorrelation function. If None is passed, 10% of
the data series length are used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>autocorr</strong> – Autocorrelation function.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (max_lag + 1,)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.get_block_length">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">get_block_length</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xyz</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#get_block_length"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.get_block_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns optimal block length for significance and confidence tests.</p>
<p>Determine block length using approach in Mader (2013) [Eq. (6)] which
improves the method of Pfeifer (2005) with non-overlapping blocks In
case of multidimensional X, the max is used. Further details in <a class="footnote-reference brackets" href="#id5" id="id26" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.
Two modes are available. For mode=’significance’, only the indices
corresponding to X are shuffled in array. For mode=’confidence’ all
variables are jointly shuffled. If the autocorrelation curve fit fails,
a block length of 5% of T is used. The block length is limited to a
maximum of 10% of T.</p>
<p>Mader et al., Journal of Neuroscience Methods,
Volume 219, Issue 2, 15 October 2013, Pages 285-291</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – data array with X, Y, Z in rows and observations in columns</p></li>
<li><p><strong>xyz</strong> (<em>array of ints</em>) – XYZ identifier array of shape (dim,).</p></li>
<li><p><strong>mode</strong> (<em>str</em>) – Which mode to use.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>block_len</strong> – Optimal block length.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.lowhighpass_filter">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">lowhighpass_filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cutperiod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pass_periods</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'low'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#lowhighpass_filter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.lowhighpass_filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Butterworth low- or high pass filter.</p>
<p>This function applies a linear filter twice, once forward and once
backwards. The combined filter has linear phase.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>cutperiod</strong> (<em>int</em>) – Period of cutoff.</p></li>
<li><p><strong>pass_periods</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'low'</em><em>)</em>) – Either ‘low’ or ‘high’ to act as a low- or high-pass filter</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>data</strong> – Filtered data array.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.ordinal_patt_array">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">ordinal_patt_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">array_mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">step</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weights</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#ordinal_patt_array"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.ordinal_patt_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns symbolified array of ordinal patterns.</p>
<p>Each data vector (X_t, …, X_t+(dim-1)*step) is converted to its rank
vector. E.g., (0.2, -.6, 1.2) –&gt; (1,0,2) which is then assigned to a
unique integer (see Article). There are faculty(dim) possible rank vectors.</p>
<p>Note that the symb_array is step*(dim-1) shorter than the original array!</p>
<p>Reference: B. Pompe and J. Runge (2011). Momentary information transfer as
a coupling measure of time series. Phys. Rev. E, 83(5), 1-12.
doi:10.1103/PhysRevE.83.051122</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>array</strong> (<em>array-like</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>array_mask</strong> (<em>bool array</em>) – Data mask where True labels masked samples.</p></li>
<li><p><strong>dim</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 2</em><em>)</em>) – Pattern dimension</p></li>
<li><p><strong>step</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Delay of pattern embedding vector.</p></li>
<li><p><strong>weights</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to return array of variances of embedding vectors as weights.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>patt, patt_mask [, patt_time]</strong> – Tuple of converted pattern array and new length</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of arrays</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.quantile_bin_array">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">quantile_bin_array</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bins</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#quantile_bin_array"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.quantile_bin_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns symbolified array with equal-quantile binning.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>bins</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Number of bins.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>symb_array</strong> – Converted data of integer type.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.smooth">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">smooth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">smooth_width</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kernel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'gaussian'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">residuals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#smooth"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.smooth" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns either smoothed time series or its residuals.</p>
<p>the difference between the original and the smoothed time series
(=residuals) of a kernel smoothing with gaussian (smoothing kernel width =
twice the sigma!) or heaviside window, equivalent to a running mean.</p>
<p>Assumes data of shape (T, N) or (T,)
:rtype: array
:returns: smoothed/residual data</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>smooth_width</strong> (<em>float</em>) – Window width of smoothing, 2*sigma for a gaussian.</p></li>
<li><p><strong>kernel</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'gaussian'</em><em>)</em>) – Smoothing kernel, ‘gaussian’ or ‘heaviside’ for a running mean.</p></li>
<li><p><strong>mask</strong> (<em>bool array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Data mask where True labels masked samples.</p></li>
<li><p><strong>residuals</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – True if residuals should be returned instead of smoothed data.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>data</strong> – Smoothed/residual data.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array-like</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.structural_causal_process">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">structural_causal_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noises</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">intervention</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">intervention_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'hard'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#structural_causal_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.structural_causal_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a structural causal process with contemporaneous and lagged
dependencies.</p>
<p>DEPRECATED. Will be removed in future.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.time_bin_with_mask">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">time_bin_with_mask</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time_bin_length</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#time_bin_with_mask"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.time_bin_with_mask" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns time binned data where only about non-masked values is averaged.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>time_bin_length</strong> (<em>int</em>) – Length of time bin.</p></li>
<li><p><strong>mask</strong> (<em>bool array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Data mask where True labels masked samples.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>(bindata, T)</strong> – Tuple of time-binned data array and new length of array.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of array and int</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.trafo2normal">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">trafo2normal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mask</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.001</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#trafo2normal"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.trafo2normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Transforms input data to standard normal marginals.</p>
<p>Assumes data.shape = (T, dim)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>thres</strong> (<em>float</em>) – Set outer points in CDF to this value.</p></li>
<li><p><strong>mask</strong> (<em>bool array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Data mask where True labels masked samples.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>normal_data</strong> – data with standard normal marginals.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array-like</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.var_process">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">var_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parents_neighbors_coeffs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'inv_inno_cov'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">initial_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#var_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.var_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a vector-autoregressive process with correlated innovations.</p>
<p>Wrapper around var_network with possibly more user-friendly input options.</p>
<p>DEPRECATED. Will be removed in future.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.data_processing.weighted_avg_and_std">
<span class="sig-prename descclassname"><span class="pre">tigramite.data_processing.</span></span><span class="sig-name descname"><span class="pre">weighted_avg_and_std</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">values</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weights</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/data_processing.html#weighted_avg_and_std"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.data_processing.weighted_avg_and_std" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the weighted average and standard deviation.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>values</strong> (<em>array</em>) – Data array of shape (time, variables).</p></li>
<li><p><strong>axis</strong> (<em>int</em>) – Axis to average/std about</p></li>
<li><p><strong>weights</strong> (<em>array</em>) – Weight array of shape (time, variables).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>(average, std)</strong> – Tuple of weighted average and standard deviation along axis.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>tuple of arrays</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="module-tigramite.toymodels.structural_causal_processes">
<span id="tigramite-toymodels-toy-model-generators"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.toymodels</span></code>: Toy model generators<a class="headerlink" href="#module-tigramite.toymodels.structural_causal_processes" title="Permalink to this heading">¶</a></h1>
<p>Tigramite toymodels.</p>
<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.check_stationarity">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">check_stationarity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#check_stationarity"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.check_stationarity" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns stationarity according to a unit root test.</p>
<p>Assumes an at least asymptotically linear vector autoregressive process
without contemporaneous links.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>links</strong> (<em>dict</em>) – Dictionary of form {0:[((0, -1), coeff, func), …], 1:[…], …}.
Also format {0:[(0, -1), …], 1:[…], …} is allowed.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>stationary</strong> – True if VAR process is stationary.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.dag_to_links">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">dag_to_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dag</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#dag_to_links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.dag_to_links" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to convert DAG graph to dictionary of parents.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>dag</strong> (<em>array of shape</em><em> (</em><em>N</em><em>, </em><em>N</em><em>, </em><em>tau_max+1</em><em>)</em>) – Matrix format of graph in string format. Must be DAG.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>parents</strong> – Dictionary of form {0:[(0, -1), …], 1:[…], …}.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.generate_structural_causal_process">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">generate_structural_causal_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">N</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">L</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dependency_funcs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">['linear']</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dependency_coeffs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[-</span> <span class="pre">0.5,</span> <span class="pre">0.5]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_coeffs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[0.5,</span> <span class="pre">0.7]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contemp_fraction</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_lag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noise_dists</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">['gaussian']</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noise_means</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[0.0]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noise_sigmas</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[0.5,</span> <span class="pre">2.0]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noise_seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#generate_structural_causal_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.generate_structural_causal_process" title="Permalink to this definition">¶</a></dt>
<dd><p>“Randomly generates a structural causal process based on input characteristics.</p>
<p>The process has the form</p>
<div class="math">
<p><img src="_images/math/c7568cb2be91af3efd87bd543226444672c4126e.png" alt="X^j_t = \eta^j_t + a^j X^j_{t-1} + \sum_{X^i_{t-\tau}\in pa(X^j_t)}
c^i_{\tau} f^i_{\tau}(X^i_{t-\tau})"/></p>
</div><p>where <code class="docutils literal notranslate"><span class="pre">j</span> <span class="pre">=</span> <span class="pre">1,</span> <span class="pre">...,</span> <span class="pre">N</span></code>. Here the properties of <img class="math" src="_images/math/aebf5e0fc00c3cf8bdbef4581708d03703b5dca7.png" alt="\eta^j_t"/> are
randomly frawn from the noise parameters (see below), <img class="math" src="_images/math/5d71aa22c129c9a9fefccd42a37ecfff31311645.png" alt="pa
(X^j_t)"/> are the causal parents drawn randomly such that in total <code class="docutils literal notranslate"><span class="pre">L</span></code>
links occur out of which <code class="docutils literal notranslate"><span class="pre">contemp_fraction</span></code> are contemporaneous and
their time lags are drawn from <code class="docutils literal notranslate"><span class="pre">[0</span> <span class="pre">or</span> <span class="pre">1..max_lag]</span></code>, the
coefficients <img class="math" src="_images/math/20efd09fac35da0e767657f265a363a8697a6c8d.png" alt="c^i_{\tau}"/> are drawn from
<code class="docutils literal notranslate"><span class="pre">dependency_coeffs</span></code>, <img class="math" src="_images/math/25bc6fbe0a632d2f173d16ac6bc4f11d108e7fe6.png" alt="a^j"/> are drawn from <code class="docutils literal notranslate"><span class="pre">auto_coeffs</span></code>,
and <img class="math" src="_images/math/8b11c561ae4561d1808b1c7d4a0321745aa3a134.png" alt="f^i_{\tau}"/> are drawn from <code class="docutils literal notranslate"><span class="pre">dependency_funcs</span></code>.</p>
<p>The returned dictionary links has the format
<code class="docutils literal notranslate"><span class="pre">{0:[((i,</span> <span class="pre">-tau),</span> <span class="pre">coeff,</span> <span class="pre">func),...],</span> <span class="pre">1:[...],</span> <span class="pre">...}</span></code>
where <code class="docutils literal notranslate"><span class="pre">func</span></code> can be an arbitrary (nonlinear) function provided
as a python callable with one argument and coeff is the multiplication
factor. The noise distributions of <img class="math" src="_images/math/be38eb4004ec8179f569f36692f9132289acf8b1.png" alt="\eta^j"/> are returned in
<code class="docutils literal notranslate"><span class="pre">noises</span></code>, see specifics below.</p>
<p>The process might be non-stationary. In case of asymptotically linear
dependency functions and no contemporaneous links this can be checked with
<code class="docutils literal notranslate"><span class="pre">check_stationarity(...)</span></code>. Otherwise check by generating a large sample
and test for np.inf.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>N</strong> (<em>int</em>) – Number of variables.</p></li>
<li><p><strong>L</strong> (<em>int</em>) – Number of cross-links between two different variables.</p></li>
<li><p><strong>dependency_funcs</strong> (<em>list</em>) – List of callables or strings ‘linear’ or ‘nonlinear’ for a linear and a specific nonlinear function
that is asymptotically linear.</p></li>
<li><p><strong>dependency_coeffs</strong> (<em>list</em>) – List of floats from which the coupling coefficients are randomly drawn.</p></li>
<li><p><strong>auto_coeffs</strong> (<em>list</em>) – List of floats from which the lag-1 autodependencies are randomly drawn.</p></li>
<li><p><strong>contemp_fraction</strong> (<em>float</em><em> [</em><em>0.</em><em>, </em><em>1</em><em>]</em>) – Fraction of the L links that are contemporaneous (lag zero).</p></li>
<li><p><strong>max_lag</strong> (<em>int</em>) – Maximum lag from which the time lags of links are drawn.</p></li>
<li><p><strong>noise_dists</strong> (<em>list</em>) – List of noise functions. Either in
{‘gaussian’, ‘weibull’, ‘uniform’} or user-specified, in which case
it must be parametrized just by the size parameter. E.g. def beta
(T): return np.random.beta(a=1, b=0.5, T)</p></li>
<li><p><strong>noise_means</strong> (<em>list</em>) – Noise mean. Only used for noise in {‘gaussian’, ‘weibull’, ‘uniform’}.</p></li>
<li><p><strong>noise_sigmas</strong> (<em>list</em>) – Noise standard deviation. Only used for noise in {‘gaussian’, ‘weibull’, ‘uniform’}.</p></li>
<li><p><strong>seed</strong> (<em>int</em>) – Random seed to draw the above random functions from.</p></li>
<li><p><strong>noise_seed</strong> (<em>int</em>) – Random seed for noise function random generator.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>links</strong> (<em>dict</em>) – Dictionary of form {0:[((0, -1), coeff, func), …], 1:[…], …}.</p></li>
<li><p><strong>noises</strong> (<em>list</em>) – List of N noise functions to call by noise(T) where T is the time series length.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.links_to_graph">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">links_to_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#links_to_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.links_to_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to convert dictionary of links to graph array format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>links</strong> (<em>dict</em>) – Dictionary of form {0:[((0, -1), coeff, func), …], 1:[…], …}.
Also format {0:[(0, -1), …], 1:[…], …} is allowed.</p></li>
<li><p><strong>tau_max</strong> (<em>int</em><em> or </em><em>None</em>) – Maximum lag. If None, the maximum lag in links is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>graph</strong> – Matrix format of graph with 1 for true links and 0 else.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array of shape (N, N, tau_max+1)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.structural_causal_process">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">structural_causal_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">noises</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">intervention</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">intervention_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'hard'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transient_fraction</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#structural_causal_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.structural_causal_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a time series generated from a structural causal process.</p>
<p>Allows lagged and contemporaneous dependencies and includes the option
to have intervened variables or particular samples.</p>
<p>The interventional data is in particular useful for generating ground
truth for the CausalEffects class.</p>
<p>In more detail, the method implements a generalized additive noise model process of the form</p>
<div class="math">
<p><img src="_images/math/04effbe50a9c1421627153afe77c1c013193dd90.png" alt="X^j_t = \eta^j_t + \sum_{X^i_{t-\tau}\in \mathcal{P}(X^j_t)}
c^i_{\tau} f^i_{\tau}(X^i_{t-\tau})"/></p>
</div><p>Links have the format <code class="docutils literal notranslate"><span class="pre">{0:[((i,</span> <span class="pre">-tau),</span> <span class="pre">coeff,</span> <span class="pre">func),...],</span> <span class="pre">1:[...],</span>
<span class="pre">...}</span></code> where <code class="docutils literal notranslate"><span class="pre">func</span></code> can be an arbitrary (nonlinear) function provided
as a python callable with one argument and coeff is the multiplication
factor. The noise distributions of <img class="math" src="_images/math/be38eb4004ec8179f569f36692f9132289acf8b1.png" alt="\eta^j"/> can be specified in
<code class="docutils literal notranslate"><span class="pre">noises</span></code>.</p>
<p>Through the parameters <code class="docutils literal notranslate"><span class="pre">intervention</span></code> and <code class="docutils literal notranslate"><span class="pre">intervention_type</span></code> the model
can also be generated with intervened variables.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>links</strong> (<em>dict</em>) – Dictionary of format: {0:[((i, -tau), coeff, func),…], 1:[…],
…} for all variables where i must be in [0..N-1] and tau &gt;= 0 with
number of variables N. coeff must be a float and func a python
callable of one argument.</p></li>
<li><p><strong>T</strong> (<em>int</em>) – Sample size.</p></li>
<li><p><strong>noises</strong> (<em>list of callables</em><em> or </em><em>array</em><em>, </em><em>optional</em><em> (</em><em>default: 'np.random.randn'</em><em>)</em>) – Random distribution function that is called with noises[j](T). If an array,
it must be of shape ((transient_fraction + 1)*T, N).</p></li>
<li><p><strong>intervention</strong> (<em>dict</em>) – Dictionary of format: {1:np.array, …} containing only keys of intervened
variables with the value being the array of length T with interventional values.
Set values to np.nan to leave specific time points of a variable un-intervened.</p></li>
<li><p><strong>intervention_type</strong> (<em>str</em><em> or </em><em>dict</em>) – Dictionary of format: {1:’hard’,  3:’soft’, …} to specify whether intervention is
hard (set value) or soft (add value) for variable j. If str, all interventions have
the same type.</p></li>
<li><p><strong>transient_fraction</strong> (<em>float</em>) – Added percentage of T used as a transient. In total a realization of length
(transient_fraction + 1)*T will be generated, but then transient_fraction*T will be
cut off.</p></li>
<li><p><strong>seed</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Random seed.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>data</strong> (<em>array-like</em>) – Data generated from this process, shape (T, N).</p></li>
<li><p><strong>nonvalid</strong> (<em>bool</em>) – Indicates whether data has NaNs or infinities.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.toymodels.structural_causal_processes.var_process">
<span class="sig-prename descclassname"><span class="pre">tigramite.toymodels.structural_causal_processes.</span></span><span class="sig-name descname"><span class="pre">var_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parents_neighbors_coeffs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'inv_inno_cov'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">initial_values</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/toymodels/structural_causal_processes.html#var_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.toymodels.structural_causal_processes.var_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a vector-autoregressive process with correlated innovations.</p>
<p>Wrapper around var_network with possibly more user-friendly input options.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>parents_neighbors_coeffs</strong> (<em>dict</em>) – Dictionary of format: {…, j:[((var1, lag1), coef1), ((var2, lag2),
coef2), …], …} for all variables where vars must be in [0..N-1]
and lags &lt;= 0 with number of variables N. If lag=0, a nonzero value
in the covariance matrix (or its inverse) is implied. These should be
the same for (i, j) and (j, i).</p></li>
<li><p><strong>use</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'inv_inno_cov'</em><em>)</em>) – Specifier, either ‘inno_cov’ or ‘inv_inno_cov’.
Any other specifier will result in non-correlated noise.
For debugging, ‘no_noise’ can also be specified, in which case random
noise will be disabled.</p></li>
<li><p><strong>T</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1000</em><em>)</em>) – Sample size.</p></li>
<li><p><strong>verbosity</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Level of verbosity.</p></li>
<li><p><strong>initial_values</strong> (<em>array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Initial values for each node. Shape must be (N, max_delay+1)</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>data</strong> (<em>array-like</em>) – Data generated from this process</p></li>
<li><p><strong>true_parent_neighbor</strong> (<em>dict</em>) – Dictionary of lists of tuples.  The dictionary is keyed by node ID, the
list stores the tuple values (parent_node_id, time_lag)</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="module-tigramite.plotting">
<span id="tigramite-plotting-plotting-functions"></span><h1><a class="reference internal" href="#module-tigramite.plotting" title="tigramite.plotting"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tigramite.plotting</span></code></a>: Plotting functions<a class="headerlink" href="#module-tigramite.plotting" title="Permalink to this heading">¶</a></h1>
<p>Tigramite plotting package.</p>
<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_densityplots">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_densityplots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">setup_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_densityplot_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_marginal_densities_on_diagonal</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_densityplots"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_densityplots" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper helper function to plot density plots.
Sets up the matrix object and plots the density plots, see parameters in
setup_density_matrix and add_densityplot.</p>
<p>The diagonal shows the marginal densities.</p>
<p>Requires seaborn.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p></li>
<li><p><strong>setup_args</strong> (<em>dict</em>) – Arguments for setting up the density plot matrix, see doc of
setup_density_matrix.</p></li>
<li><p><strong>add_densityplot_args</strong> (<em>dict</em>) – Arguments for adding a density plot matrix.</p></li>
<li><p><strong>selected_dataset</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – In case of multiple datasets in dataframe, plot this one.</p></li>
<li><p><strong>show_marginal_densities_on_diagonal</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Flag to show marginal densities on the diagonal of the density plots</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>matrix</strong> – Further density plots can be overlaid using the
matrix.add_densityplot function.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>object</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_graph">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fig_ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'MCI'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'auto-MCI'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_attribute</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_pos</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrow_linewidth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">8.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">edge_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_aspect</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrowhead_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">curved_radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_array</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_colorbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inner_edge_style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'dashed'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">special_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_autodependency_lags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a network plot.</p>
<p>This is still in beta. The network is defined from links in graph. Nodes
denote variables, straight links contemporaneous dependencies and curved
arrows lagged dependencies. The node color denotes the maximal absolute
auto-dependency and the link color the value at the lag with maximal
absolute cross-dependency. The link label lists the lags with significant
dependency in order of absolute magnitude. The network can also be
plotted over a map drawn before on the same axis. Then the node positions
can be supplied in appropriate axis coordinates via node_pos.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>string</em><em> or </em><em>bool array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Either string matrix providing graph or bool array providing only adjacencies
Must be of same shape as val_matrix.</p></li>
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing test statistic values.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>fig_ax</strong> (<em>tuple of figure and axis object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure and axes instance. If None they are created.</p></li>
<li><p><strong>figsize</strong> (<em>tuple</em>) – Size of figure.</p></li>
<li><p><strong>save_name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>link_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'MCI'</em><em>)</em>) – Test statistic label.</p></li>
<li><p><strong>node_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'auto-MCI'</em><em>)</em>) – Test statistic label for auto-dependencies.</p></li>
<li><p><strong>link_width</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of val_matrix.shape specifying relative link width with maximum
given by arrow_linewidth. If None, all links have same width.</p></li>
<li><p><strong>link_attribute</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – String array of val_matrix.shape specifying link attributes.</p></li>
<li><p><strong>node_pos</strong> (<em>dictionary</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Dictionary of node positions in axis coordinates of form
node_pos = {‘x’:array of shape (N,), ‘y’:array of shape(N)}. These
coordinates could have been transformed before for basemap plots. You can
also add a key ‘transform’:ccrs.PlateCarree() in order to plot graphs on
a map using cartopy.</p></li>
<li><p><strong>arrow_linewidth</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 30</em><em>)</em>) – Linewidth.</p></li>
<li><p><strong>vmin_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Link colorbar scale lower bound.</p></li>
<li><p><strong>vmax_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Link colorbar scale upper bound.</p></li>
<li><p><strong>edge_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Link tick mark interval.</p></li>
<li><p><strong>cmap_edges</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'RdBu_r'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>vmin_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Node colorbar scale lower bound.</p></li>
<li><p><strong>vmax_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Node colorbar scale upper bound.</p></li>
<li><p><strong>node_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Node tick mark interval.</p></li>
<li><p><strong>cmap_nodes</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'OrRd'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>node_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0.3</em><em>)</em>) – Node size.</p></li>
<li><p><strong>node_aspect</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Ratio between the heigth and width of the varible nodes.</p></li>
<li><p><strong>arrowhead_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 20</em><em>)</em>) – Size of link arrow head. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>curved_radius</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>float</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>(</strong><strong>default</strong> (<em>optional</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of colorbar labels.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
<li><p><strong>node_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of node labels.</p></li>
<li><p><strong>link_label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of link labels.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>lag_array</strong> (<em>array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional specification of lags overwriting np.arange(0, tau_max+1)</p></li>
<li><p><strong>show_colorbar</strong> (<em>bool</em>) – Whether to show colorbars for links and nodes.</p></li>
<li><p><strong>show_autodependency_lags</strong> (<em>bool</em><em> (</em><em>default: False</em><em>)</em>) – Shows significant autodependencies for a node.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_lagfuncs">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_lagfuncs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">setup_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_lagfunc_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_lagfuncs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_lagfuncs" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper helper function to plot lag functions.
Sets up the matrix object and plots the lagfunction, see parameters in
setup_matrix and add_lagfuncs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing test statistic values.</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p></li>
<li><p><strong>setup_args</strong> (<em>dict</em>) – Arguments for setting up the lag function matrix, see doc of
setup_matrix.</p></li>
<li><p><strong>add_lagfunc_args</strong> (<em>dict</em>) – Arguments for adding a lag function matrix, see doc of add_lagfuncs.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>matrix</strong> – Further lag functions can be overlaid using the
matrix.add_lagfuncs(val_matrix) function.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>object</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_mediation_graph">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_mediation_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path_val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">path_node_array</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fig_ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'link</span> <span class="pre">coeff.</span> <span class="pre">(edge</span> <span class="pre">color)'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'MCE</span> <span class="pre">(node</span> <span class="pre">color)'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_pos</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrow_linewidth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">edge_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_aspect</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrowhead_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">curved_radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_array</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'lightgrey'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_mediation_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_mediation_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a network plot visualizing the pathways of a mediation analysis.
This is still in beta. The network is defined from non-zero entries in
<code class="docutils literal notranslate"><span class="pre">path_val_matrix</span></code>.  Nodes denote variables, straight links contemporaneous
dependencies and curved arrows lagged dependencies. The node color denotes
the mediated causal effect (MCE) and the link color the value at the lag
with maximal link coefficient. The link label lists the lags with
significant dependency in order of absolute magnitude. The network can also
be plotted over a map drawn before on the same axis. Then the node positions
can be supplied in appropriate axis coordinates via node_pos.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>path_val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing link weight values.</p></li>
<li><p><strong>path_node_array</strong> (<em>array_like</em>) – Array of shape (N,) containing node values.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>fig_ax</strong> (<em>tuple of figure and axis object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure and axes instance. If None they are created.</p></li>
<li><p><strong>figsize</strong> (<em>tuple</em>) – Size of figure.</p></li>
<li><p><strong>save_name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>link_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'link coeff.</em><em> (</em><em>edge color</em><em>)</em><em>'</em><em>)</em>) – Link colorbar label.</p></li>
<li><p><strong>node_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'MCE</em><em> (</em><em>node color</em><em>)</em><em>'</em><em>)</em>) – Node colorbar label.</p></li>
<li><p><strong>link_width</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of val_matrix.shape specifying relative link width with maximum
given by arrow_linewidth. If None, all links have same width.</p></li>
<li><p><strong>node_pos</strong> (<em>dictionary</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Dictionary of node positions in axis coordinates of form
node_pos = {‘x’:array of shape (N,), ‘y’:array of shape(N)}. These
coordinates could have been transformed before for basemap plots. You can
also add a key ‘transform’:ccrs.PlateCarree() in order to plot graphs on
a map using cartopy.</p></li>
<li><p><strong>arrow_linewidth</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 30</em><em>)</em>) – Linewidth.</p></li>
<li><p><strong>vmin_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Link colorbar scale lower bound.</p></li>
<li><p><strong>vmax_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Link colorbar scale upper bound.</p></li>
<li><p><strong>edge_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Link tick mark interval.</p></li>
<li><p><strong>cmap_edges</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'RdBu_r'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>vmin_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Node colorbar scale lower bound.</p></li>
<li><p><strong>vmax_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Node colorbar scale upper bound.</p></li>
<li><p><strong>node_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Node tick mark interval.</p></li>
<li><p><strong>cmap_nodes</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'OrRd'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>node_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0.3</em><em>)</em>) – Node size.</p></li>
<li><p><strong>node_aspect</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Ratio between the heigth and width of the varible nodes.</p></li>
<li><p><strong>arrowhead_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 20</em><em>)</em>) – Size of link arrow head. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>curved_radius</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>float</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>(</strong><strong>default</strong> (<em>optional</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of colorbar labels.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
<li><p><strong>node_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of node labels.</p></li>
<li><p><strong>link_label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of link labels.</p></li>
<li><p><strong>lag_array</strong> (<em>array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional specification of lags overwriting np.arange(0, tau_max+1)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_mediation_time_series_graph">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_mediation_time_series_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path_node_array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tsg_path_val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fig_ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'link</span> <span class="pre">coeff.</span> <span class="pre">(edge</span> <span class="pre">color)'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'MCE</span> <span class="pre">(node</span> <span class="pre">color)'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrow_linewidth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">8</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">edge_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_aspect</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrowhead_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">curved_radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">12</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">12</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'lightgrey'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_mediation_time_series_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_mediation_time_series_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a mediation time series graph plot.
This is still in beta. The time series graph’s links are colored by
val_matrix.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>tsg_path_val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N*tau_max, N*tau_max) containing link weight values.</p></li>
<li><p><strong>path_node_array</strong> (<em>array_like</em>) – Array of shape (N,) containing node values.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>fig_ax</strong> (<em>tuple of figure and axis object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure and axes instance. If None they are created.</p></li>
<li><p><strong>figsize</strong> (<em>tuple</em>) – Size of figure.</p></li>
<li><p><strong>save_name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>link_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'link coeff.</em><em> (</em><em>edge color</em><em>)</em><em>'</em><em>)</em>) – Link colorbar label.</p></li>
<li><p><strong>node_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'MCE</em><em> (</em><em>node color</em><em>)</em><em>'</em><em>)</em>) – Node colorbar label.</p></li>
<li><p><strong>link_width</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of val_matrix.shape specifying relative link width with maximum
given by arrow_linewidth. If None, all links have same width.</p></li>
<li><p><strong>order</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – order of variables from top to bottom.</p></li>
<li><p><strong>arrow_linewidth</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 30</em><em>)</em>) – Linewidth.</p></li>
<li><p><strong>vmin_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Link colorbar scale lower bound.</p></li>
<li><p><strong>vmax_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Link colorbar scale upper bound.</p></li>
<li><p><strong>edge_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Link tick mark interval.</p></li>
<li><p><strong>cmap_edges</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'RdBu_r'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>vmin_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – Node colorbar scale lower bound.</p></li>
<li><p><strong>vmax_nodes</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Node colorbar scale upper bound.</p></li>
<li><p><strong>node_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Node tick mark interval.</p></li>
<li><p><strong>cmap_nodes</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'OrRd'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>node_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Node size.</p></li>
<li><p><strong>node_aspect</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Ratio between the heigth and width of the varible nodes.</p></li>
<li><p><strong>arrowhead_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 20</em><em>)</em>) – Size of link arrow head. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>curved_radius</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>float</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>(</strong><strong>default</strong> (<em>optional</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of colorbar labels.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
<li><p><strong>node_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of node labels.</p></li>
<li><p><strong>link_label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of link labels.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_scatterplots">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_scatterplots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">setup_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_scatterplot_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_scatterplots"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_scatterplots" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper helper function to plot scatter plots.
Sets up the matrix object and plots the scatter plots, see parameters in
setup_scatter_matrix and add_scatterplot.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p></li>
<li><p><strong>setup_args</strong> (<em>dict</em>) – Arguments for setting up the scatter plot matrix, see doc of
setup_scatter_matrix.</p></li>
<li><p><strong>add_scatterplot_args</strong> (<em>dict</em>) – Arguments for adding a scatter plot matrix.</p></li>
<li><p><strong>selected_dataset</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – In case of multiple datasets in dataframe, plot this one.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>matrix</strong> – Further scatter plot can be overlaid using the
matrix.add_scatterplot function.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>object</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_time_series_graph">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_time_series_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fig_ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_colorbar_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'MCI'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_attribute</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrow_linewidth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmin_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vmax_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">edge_ticks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap_edges</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'RdBu_r'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_aspect</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">arrowhead_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">20</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">curved_radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inner_edge_style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'dashed'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">special_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_classification</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_links</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">standard_color_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'lightgrey'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_time_series_graph"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_time_series_graph" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a time series graph.
This is still in beta. The time series graph’s links are colored by
val_matrix.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>string</em><em> or </em><em>bool array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Either string matrix providing graph or bool array providing only adjacencies
Either of shape (N, N, tau_max + 1) or as auxiliary graph of dims
(N, N, tau_max+1, tau_max+1) describing auxADMG.</p></li>
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of same shape as graph containing test statistic values.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>fig_ax</strong> (<em>tuple of figure and axis object</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure and axes instance. If None they are created.</p></li>
<li><p><strong>figsize</strong> (<em>tuple</em>) – Size of figure.</p></li>
<li><p><strong>save_name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>link_colorbar_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'MCI'</em><em>)</em>) – Test statistic label.</p></li>
<li><p><strong>link_width</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of val_matrix.shape specifying relative link width with maximum
given by arrow_linewidth. If None, all links have same width.</p></li>
<li><p><strong>link_attribute</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of graph.shape specifying specific in drawing the graph (for internal use).</p></li>
<li><p><strong>order</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – order of variables from top to bottom.</p></li>
<li><p><strong>arrow_linewidth</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 30</em><em>)</em>) – Linewidth.</p></li>
<li><p><strong>vmin_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Link colorbar scale lower bound.</p></li>
<li><p><strong>vmax_edges</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Link colorbar scale upper bound.</p></li>
<li><p><strong>edge_ticks</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.4</em><em>)</em>) – Link tick mark interval.</p></li>
<li><p><strong>cmap_edges</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'RdBu_r'</em><em>)</em>) – Colormap for links.</p></li>
<li><p><strong>node_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Node size.</p></li>
<li><p><strong>node_aspect</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Ratio between the heigth and width of the varible nodes.</p></li>
<li><p><strong>arrowhead_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 20</em><em>)</em>) – Size of link arrow head. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>curved_radius</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>float</strong> (<em>0.2</em><em>)</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>(</strong><strong>default</strong> (<em>optional</em>) – Curvature of links. Passed on to FancyArrowPatch object.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of colorbar labels.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
<li><p><strong>node_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of node labels.</p></li>
<li><p><strong>link_label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of link labels.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>inner_edge_style</strong> (<em>string</em><em>, </em><em>optional</em><em> (</em><em>default: 'dashed'</em><em>)</em>) – Style of inner_edge contemporaneous links.</p></li>
<li><p><strong>special_nodes</strong> (<em>dict</em>) – Dictionary of format {(i, -tau): ‘blue’, …} to color special nodes.</p></li>
<li><p><strong>node_classification</strong> (<em>dict</em><em> or </em><em>None</em><em> (</em><em>default: None</em><em>)</em>) – Dictionary of format {i: ‘space_context’, …} to classify nodes into system, context, or dummy nodes.
Keys of the dictionary are from {0, …, N-1} where N is the number of nodes.
Options for the values are “system”, “time_context”, “space_context”, “time_dummy”, or “space_dummy”.
Space_contexts and dummy nodes need to be represented as a single node in the time series graph.
In case no value is supplied all nodes are treated as system nodes, i.e. are plotted in a time-resolved manner.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_timeseries">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_timeseries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fig_axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_units</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">grey_masked_samples</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_meanline</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_linewidth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">skip_ticks_data_x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">skip_ticks_data_y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adjust_plot</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_variables</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_timeseries"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_timeseries" title="Permalink to this definition">¶</a></dt>
<dd><p>Create and save figure of stacked panels with time series.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em><em>, </em><em>optional</em>) – This is the Tigramite dataframe object. It has the attributes
dataframe.values yielding a np array of shape (observations T,
variables N) and optionally a mask of the same shape.</p></li>
<li><p><strong>save_name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>fig_axes</strong> (<em>subplots instance</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure and axes instance. If None they are created as
fig, axes = pyplot.subplots(N,…)</p></li>
<li><p><strong>figsize</strong> (<em>tuple of floats</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure size if new figure is created. If None, default pyplot figsize
is used.</p></li>
<li><p><strong>var_units</strong> (<em>list of str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Units of variables.</p></li>
<li><p><strong>time_label</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: ''</em><em>)</em>) – Label of time axis.</p></li>
<li><p><strong>grey_masked_samples</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to mark masked samples by grey fills (‘fill’) or grey data
(‘data’).</p></li>
<li><p><strong>show_meanline</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to plot a horizontal line at the mean.</p></li>
<li><p><strong>data_linewidth</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Linewidth.</p></li>
<li><p><strong>skip_ticks_data_x</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Skip every other tickmark.</p></li>
<li><p><strong>skip_ticks_data_y</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 2</em><em>)</em>) – Skip every other tickmark.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of variable labels.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>color</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: black</em><em>)</em>) – Line color.</p></li>
<li><p><strong>alpha</strong> (<em>float</em>) – Alpha opacity.</p></li>
<li><p><strong>selected_dataset</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – In case of multiple datasets in dataframe, plot this one.</p></li>
<li><p><strong>selected_variables</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variables which to plot.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.plot_tsg">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">plot_tsg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">links</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">anc_x</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">anc_y</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">anc_xy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#plot_tsg"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.plot_tsg" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots TSG that is input in format (N*max_lag, N*max_lag).
Compared to the tigramite plotting function here links
X^i_{t-tau} –&gt; X^j_t can be missing for different t’. Helpful to
visualize the conditioned TSG.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.plotting.setup_density_matrix">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">setup_density_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">N</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_left</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_top</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">plot_gridlines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_density_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_density_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Create matrix of density plot panels.
Class to setup figure object. The function add_densityplot allows to plot
density plots of variables in the dataframe.</p>
<p>Further density plots can be overlaid using the matrix.add_densityplot
function.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>N</strong> (<em>int</em>) – Number of variables</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>figsize</strong> (<em>tuple of floats</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure size if new figure is created. If None, default pyplot figsize
is used.</p></li>
<li><p><strong>label_space_left</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Fraction of horizontal figure space to allocate left of plot for labels.</p></li>
<li><p><strong>label_space_top</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Fraction of vertical figure space to allocate top of plot for labels.</p></li>
<li><p><strong>legend_width</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.15</em><em>)</em>) – Fraction of horizontal figure space to allocate right of plot for
legend.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>plot_gridlines</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to show a grid.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of variable labels.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_density_matrix.add_densityplot">
<span class="sig-name descname"><span class="pre">add_densityplot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">matrix_lags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">snskdeplot_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{'cmap':</span> <span class="pre">'Greys'}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">snskdeplot_diagonal_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_marginal_densities_on_diagonal</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_density_matrix.add_densityplot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_density_matrix.add_densityplot" title="Permalink to this definition">¶</a></dt>
<dd><p>Add density function plot.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>matrix_lags</strong> (<em>array</em>) – Lags to use in scatter plots. Either None or non-neg array of shape (N, N). Then the
entry matrix_lags[i, j] = tau will depict the scatter plot of
time series (i, -tau) vs (j, 0). If None, tau = 0 for i != j and for i = j
tau = 1.</p></li>
<li><p><strong>snskdeplot_args</strong> (<em>dict</em>) – Optional parameters to pass to sns.kdeplot() for i != j for off-diagonal plots.</p></li>
<li><p><strong>snskdeplot_diagonal_args</strong> (<em>dict</em>) – Optional parameters to pass to sns.kdeplot() for i == j on diagonal.</p></li>
<li><p><strong>label</strong> (<em>string</em>) – Label of this plot.</p></li>
<li><p><strong>label_color</strong> (<em>string</em>) – Color of line created just for legend.</p></li>
<li><p><strong>selected_dataset</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – In case of multiple datasets in dataframe, plot this one.</p></li>
<li><p><strong>show_marginal_densities_on_diagonal</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Flag to show marginal densities on the diagonal of the density plots</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_density_matrix.adjustfig">
<span class="sig-name descname"><span class="pre">adjustfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show_labels</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_density_matrix.adjustfig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_density_matrix.adjustfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust matrix figure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.plotting.setup_matrix">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">setup_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">N</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_max</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minimum</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maximum</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_left</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_top</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_base</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_base</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">plot_gridlines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_units</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lag_array</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Create matrix of lag function panels.
Class to setup figure object. The function add_lagfuncs(…) allows to plot
the val_matrix of shape (N, N, tau_max+1). Multiple lagfunctions can be
overlaid for comparison.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>N</strong> (<em>int</em>) – Number of variables</p></li>
<li><p><strong>tau_max</strong> (<em>int</em>) – Maximum time lag.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>figsize</strong> (<em>tuple of floats</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure size if new figure is created. If None, default pyplot figsize
is used.</p></li>
<li><p><strong>minimum</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: -1</em><em>)</em>) – Lower y-axis limit.</p></li>
<li><p><strong>maximum</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 1</em><em>)</em>) – Upper y-axis limit.</p></li>
<li><p><strong>label_space_left</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Fraction of horizontal figure space to allocate left of plot for labels.</p></li>
<li><p><strong>label_space_top</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Fraction of vertical figure space to allocate top of plot for labels.</p></li>
<li><p><strong>legend_width</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.15</em><em>)</em>) – Fraction of horizontal figure space to allocate right of plot for
legend.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>x_base</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – x-tick intervals to show.</p></li>
<li><p><strong>y_base</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: .4</em><em>)</em>) – y-tick intervals to show.</p></li>
<li><p><strong>plot_gridlines</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to show a grid.</p></li>
<li><p><strong>lag_units</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: ''</em><em>)</em>) – </p></li>
<li><p><strong>lag_array</strong> (<em>array</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Optional specification of lags overwriting np.arange(0, tau_max+1)</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of variable labels.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_matrix.add_lagfuncs">
<span class="sig-name descname"><span class="pre">add_lagfuncs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sig_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">two_sided_thres</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">marker</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'.'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">markersize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_matrix.add_lagfuncs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_matrix.add_lagfuncs" title="Permalink to this definition">¶</a></dt>
<dd><p>Add lag function plot from val_matrix array.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing test statistic values.</p></li>
<li><p><strong>sig_thres</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Matrix of significance thresholds. Must be of same shape as
val_matrix.</p></li>
<li><p><strong>conf_matrix</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Matrix of shape (, N, tau_max+1, 2) containing confidence bounds.</p></li>
<li><p><strong>color</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'black'</em><em>)</em>) – Line color.</p></li>
<li><p><strong>label</strong> (<em>str</em>) – Test statistic label.</p></li>
<li><p><strong>two_sided_thres</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: True</em><em>)</em>) – Whether to draw sig_thres for pos. and neg. values.</p></li>
<li><p><strong>marker</strong> (<em>matplotlib marker symbol</em><em>, </em><em>optional</em><em> (</em><em>default: '.'</em><em>)</em>) – Marker.</p></li>
<li><p><strong>markersize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 5</em><em>)</em>) – Marker size.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_matrix.savefig">
<span class="sig-name descname"><span class="pre">savefig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_matrix.savefig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_matrix.savefig" title="Permalink to this definition">¶</a></dt>
<dd><p>Save matrix figure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tigramite.plotting.setup_scatter_matrix">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">setup_scatter_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">N</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">figsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_left</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_space_top</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.15</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">plot_gridlines</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tick_label_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_scatter_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_scatter_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Create matrix of scatter plot panels.
Class to setup figure object. The function add_scatterplot allows to plot
scatterplots of variables in the dataframe. Multiple scatter plots can be
overlaid for comparison.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>N</strong> (<em>int</em>) – Number of variables</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>figsize</strong> (<em>tuple of floats</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Figure size if new figure is created. If None, default pyplot figsize
is used.</p></li>
<li><p><strong>label_space_left</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.1</em><em>)</em>) – Fraction of horizontal figure space to allocate left of plot for labels.</p></li>
<li><p><strong>label_space_top</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.05</em><em>)</em>) – Fraction of vertical figure space to allocate top of plot for labels.</p></li>
<li><p><strong>legend_width</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 0.15</em><em>)</em>) – Fraction of horizontal figure space to allocate right of plot for
legend.</p></li>
<li><p><strong>tick_label_size</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 6</em><em>)</em>) – Fontsize of tick labels.</p></li>
<li><p><strong>plot_gridlines</strong> (<em>bool</em><em>, </em><em>optional</em><em> (</em><em>default: False</em><em>)</em>) – Whether to show a grid.</p></li>
<li><p><strong>label_fontsize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 10</em><em>)</em>) – Fontsize of variable labels.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_scatter_matrix.add_scatterplot">
<span class="sig-name descname"><span class="pre">add_scatterplot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dataframe</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">matrix_lags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'black'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">marker</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'.'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">markersize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selected_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_scatter_matrix.add_scatterplot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_scatter_matrix.add_scatterplot" title="Permalink to this definition">¶</a></dt>
<dd><p>Add scatter plot.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataframe</strong> (<em>data object</em>) – Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.</p></li>
<li><p><strong>matrix_lags</strong> (<em>array</em>) – Lags to use in scatter plots. Either None or of shape (N, N). Then the
entry matrix_lags[i, j] = tau will depict the scatter plot of
time series (i, -tau) vs (j, 0). If None, tau = 0 for i != j and for i = j
tau = 1.</p></li>
<li><p><strong>color</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: 'black'</em><em>)</em>) – Line color.</p></li>
<li><p><strong>label</strong> (<em>str</em>) – Test statistic label.</p></li>
<li><p><strong>marker</strong> (<em>matplotlib marker symbol</em><em>, </em><em>optional</em><em> (</em><em>default: '.'</em><em>)</em>) – Marker.</p></li>
<li><p><strong>markersize</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 5</em><em>)</em>) – Marker size.</p></li>
<li><p><strong>alpha</strong> (<em>float</em><em>, </em><em>optional</em><em> (</em><em>default: 1.</em><em>)</em>) – Opacity.</p></li>
<li><p><strong>selected_dataset</strong> (<em>int</em><em>, </em><em>optional</em><em> (</em><em>default: 0</em><em>)</em>) – In case of multiple datasets in dataframe, plot this one.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tigramite.plotting.setup_scatter_matrix.adjustfig">
<span class="sig-name descname"><span class="pre">adjustfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#setup_scatter_matrix.adjustfig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.setup_scatter_matrix.adjustfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust matrix figure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – File name. If None, figure is shown in window.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tigramite.plotting.write_csv">
<span class="sig-prename descclassname"><span class="pre">tigramite.plotting.</span></span><span class="sig-name descname"><span class="pre">write_csv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_matrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">link_attribute</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">digits</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tigramite/plotting.html#write_csv"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tigramite.plotting.write_csv" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes all links in a graph to a csv file.</p>
<p>Format is each link in a row as ‘Variable i’, ‘Variable j’, ‘Time lag of i’, ‘Link type i — j’,
with optional further columns for entries in [val_matrix link_attribute, link_width].</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>graph</strong> (<em>string</em><em> or </em><em>bool array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Either string matrix providing graph or bool array providing only adjacencies
Must be of same shape as val_matrix.</p></li>
<li><p><strong>save_name</strong> (<em>str</em>) – Name of figure file to save figure. If None, figure is shown in window.</p></li>
<li><p><strong>val_matrix</strong> (<em>array_like</em>) – Matrix of shape (N, N, tau_max+1) containing test statistic values.</p></li>
<li><p><strong>var_names</strong> (<em>list</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – List of variable names. If None, range(N) is used.</p></li>
<li><p><strong>link_width</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – Array of val_matrix.shape specifying relative link width with maximum
given by arrow_linewidth. If None, all links have same width.</p></li>
<li><p><strong>link_attribute</strong> (<em>array-like</em><em>, </em><em>optional</em><em> (</em><em>default: None</em><em>)</em>) – String array of val_matrix.shape specifying link attributes.</p></li>
<li><p><strong>digits</strong> (<em>int</em>) – Number of significant digits for writing link value and width.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</section>
<section id="id27">
<h1>Indices and tables<a class="headerlink" href="#id27" title="Permalink to this heading">¶</a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</section>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="#">Tigramite</a></h1>








<h3>Navigation</h3>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="#">Documentation overview</a><ul>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2023, Jakob Runge.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 5.0.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/index.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>